LCOV - code coverage report
Current view: top level - backend - taler-merchant-httpd_spa.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 84.2 % 19 16
Test Date: 2025-11-28 21:09:21 Functions: 100.0 % 3 3

            Line data    Source code
       1              : /*
       2              :   This file is part of TALER
       3              :   Copyright (C) 2020, 2023, 2025 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 MERCHANTABILITY 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-merchant-httpd_spa.c
      18              :  * @brief logic to load the single page app (/)
      19              :  * @author Christian Grothoff
      20              :  */
      21              : #include "platform.h"
      22              : #include <gnunet/gnunet_util_lib.h>
      23              : #include <taler/taler_util.h>
      24              : #include <taler/taler_mhd_lib.h>
      25              : #include "taler_merchant_util.h"
      26              : #include "taler-merchant-httpd_statics.h"
      27              : #include "taler-merchant-httpd_spa.h"
      28              : #include <gnunet/gnunet_mhd_compat.h>
      29              : 
      30              : 
      31              : /**
      32              :  * Resources of the Merchant SPA.
      33              :  */
      34              : static struct TALER_MHD_Spa *spa;
      35              : 
      36              : 
      37              : MHD_RESULT
      38            1 : TMH_return_spa (const struct TMH_RequestHandler *rh,
      39              :                 struct MHD_Connection *connection,
      40              :                 struct TMH_HandlerContext *hc)
      41              : {
      42            1 :   const char *infix = hc->infix;
      43              : 
      44            1 :   if ( (NULL == infix) ||
      45            1 :        (0 == strcmp (infix,
      46              :                      "")) )
      47            1 :     infix = "index.html";
      48            1 :   return TALER_MHD_spa_handler (spa,
      49              :                                 connection,
      50              :                                 infix);
      51              : }
      52              : 
      53              : 
      54              : enum GNUNET_GenericReturnValue
      55           15 : TMH_spa_init (const char *spa_dir)
      56              : {
      57           15 :   if (NULL == spa_dir)
      58           15 :     spa = TALER_MHD_spa_load (TALER_MERCHANT_project_data (),
      59              :                               "spa/");
      60              :   else
      61            0 :     spa = TALER_MHD_spa_load_dir (spa_dir);
      62              : 
      63           15 :   if (NULL == spa)
      64              :   {
      65            0 :     GNUNET_break (0);
      66            0 :     return GNUNET_SYSERR;
      67              :   }
      68           15 :   return GNUNET_OK;
      69              : }
      70              : 
      71              : 
      72              : /**
      73              :  * Nicely shut down.
      74              :  */
      75              : void __attribute__ ((destructor))
      76              : get_spa_fini (void);
      77              : 
      78              : /* Declaration to avoid compiler warning */
      79              : void __attribute__ ((destructor))
      80           29 : get_spa_fini ()
      81              : {
      82           29 :   if (NULL != spa)
      83              :   {
      84           15 :     TALER_MHD_spa_free (spa);
      85           15 :     spa = NULL;
      86              :   }
      87           29 : }
        

Generated by: LCOV version 2.0-1