paivana

HTTP paywall reverse proxy
Log | Files | Refs | Submodules | README | LICENSE

paivana-httpd_templates.h (2715B)


      1 /*
      2      This file is part of GNUnet.
      3      Copyright (C) 2026 Taler Systems SA
      4 
      5      Paivana is free software; you can redistribute it and/or
      6      modify it under the terms of the GNU Affero General Public License
      7      as published by the Free Software Foundation; either version
      8      3, or (at your option) any later version.
      9 
     10      Paivana is distributed in the hope that it will be useful,
     11      but WITHOUT ANY WARRANTY; without even the implied warranty
     12      of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
     13      the GNU Affero General Public License for more details.
     14 
     15      You should have received a copy of the GNU Affero General Public
     16      License along with Paivana; see the file COPYING.  If not,
     17      write to the Free Software Foundation, Inc., 51 Franklin
     18      Street, Fifth Floor, Boston, MA 02110-1301, USA.
     19 */
     20 
     21 /**
     22  * @author Christian Grothoff
     23  * @file paivana-httpd_templates.h
     24  * @brief functions to work with merchant backend templates
     25  */
     26 #ifndef PAIVANA_HTTPD_TEMPLATES_H
     27 #define PAIVANA_HTTPD_TEMPLATES_H
     28 
     29 #include <microhttpd.h>
     30 #include <stdbool.h>
     31 #include <gnunet/gnunet_util_lib.h>
     32 
     33 
     34 /**
     35  * Discover the installed paywall languages used to normalize response-cache
     36  * keys.  Must be called after TALER_TEMPLATING_init().
     37  *
     38  * @return true if at least one and at most the supported maximum are present
     39  */
     40 bool
     41 PAIVANA_HTTPD_init_template_languages (void);
     42 
     43 
     44 /**
     45  * Load the templates from the merchant backend.  Calls
     46  * PAIVANA_HTTPD_serve_requests() upon completion if successful,
     47  * otherwise may initiate shutdown.
     48  */
     49 void
     50 PAIVANA_HTTPD_load_templates (void);
     51 
     52 
     53 /**
     54  * Redirect to the paywall page for the given @a website.
     55  *
     56  * @param connection request to search paywall response for
     57  * @param website site to look for paywall templates for
     58  * @return #GNUNET_OK if a response was queued -- the redirect to the
     59  *         paywall, but also the 414 for an over-long @a website and
     60  *         the 400 for a request we cannot build a base URL for,
     61  *         #GNUNET_NO to close the connection with error,
     62  *         #GNUNET_SYSERR if there is no paywall for @a website
     63  */
     64 enum GNUNET_GenericReturnValue
     65 PAIVANA_HTTPD_search_templates (struct MHD_Connection *connection,
     66                                 const char *website);
     67 
     68 
     69 /**
     70  * Return the paywall page for the given @a template.
     71  *
     72  * @param connection request to search paywall response for
     73  * @param template template to return paywall page for
     74  * @return MHD status code
     75  */
     76 enum MHD_Result
     77 PAIVANA_HTTPD_return_template (struct MHD_Connection *connection,
     78                                const char *template);
     79 
     80 
     81 /**
     82  * Unload all of the template state.
     83  */
     84 void
     85 PAIVANA_HTTPD_unload_templates (void);
     86 
     87 #endif