exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

taler-auditor-httpd_spa.c (2102B)


      1 /*
      2   This file is part of TALER
      3   Copyright (C) 2020, 2023, 2024 Taler Systems SA
      4 
      5   TALER is free software; you can redistribute it and/or modify it under the
      6   terms of the GNU General Public License as published by the Free Software
      7   Foundation; either version 3, or (at your option) any later version.
      8 
      9   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     10   WARRANTY; without even the implied warranty of EXCHANGEABILITY or FITNESS FOR
     11   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12 
     13   You should have received a copy of the GNU General Public License along with
     14   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15 */
     16 /**
     17  * @file taler-auditor-httpd_spa.c
     18  * @brief logic to load single page app (/spa)
     19  * @author Christian Grothoff
     20  */
     21 #include "taler/platform.h"
     22 #include <gnunet/gnunet_util_lib.h>
     23 #include "taler/taler_util.h"
     24 #include "taler/taler_mhd_lib.h"
     25 #include <gnunet/gnunet_mhd_compat.h>
     26 #include "taler-auditor-httpd_spa.h"
     27 
     28 
     29 /**
     30  * Resources of the auditor SPA.
     31  */
     32 static struct TALER_MHD_Spa *spa;
     33 
     34 
     35 MHD_RESULT
     36 TAH_spa_handler (
     37   /* const */ struct TAH_RequestHandler *rh,
     38   struct MHD_Connection *connection,
     39   void **connection_cls,
     40   const char *upload_data,
     41   size_t *upload_data_size,
     42   const char *const args[])
     43 {
     44   const char *path = args[1];
     45 
     46   GNUNET_assert (0 == strcmp (args[0],
     47                               "spa"));
     48   if (NULL == path)
     49     path = "index.html";
     50   return TALER_MHD_spa_handler (spa,
     51                                 connection,
     52                                 path);
     53 }
     54 
     55 
     56 enum GNUNET_GenericReturnValue
     57 TAH_spa_init ()
     58 {
     59   spa = TALER_MHD_spa_load (TALER_AUDITOR_project_data (),
     60                             "spa/");
     61   if (NULL == spa)
     62   {
     63     GNUNET_break (0);
     64     return GNUNET_SYSERR;
     65   }
     66   return GNUNET_OK;
     67 }
     68 
     69 
     70 /**
     71  * Nicely shut down.
     72  */
     73 void __attribute__ ((destructor))
     74 get_spa_fini (void);
     75 
     76 /* declaration to suppress compiler warning */
     77 void __attribute__ ((destructor))
     78 get_spa_fini ()
     79 {
     80   if (NULL != spa)
     81   {
     82     TALER_MHD_spa_free (spa);
     83     spa = NULL;
     84   }
     85 }