donau

Donation authority for GNU Taler (experimental)
Log | Files | Refs | Submodules | README | LICENSE

commit bddae683fca33dc84afb1e857b1307ebfd008599
parent fd66e90bde7f7a59117e832af5e0a385df47ad1e
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
Date:   Mon, 15 Jan 2024 17:54:40 +0100

[httpd] added charities get helper

Diffstat:
Msrc/donau/donau-httpd.c | 30++++++++++++++++++++++++++++--
Msrc/donau/donau-httpd_charity.h | 4++--
Msrc/donau/donau-httpd_get-charity.c | 11+----------
3 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/src/donau/donau-httpd.c b/src/donau/donau-httpd.c @@ -34,6 +34,7 @@ #include "donau-httpd_config.h" #include "donau-httpd_keys.h" #include "donau-httpd_charity.h" +#include "donau-httpd_history.h" #include "donau-httpd_terms.h" #include "donaudb_plugin.h" #include <gnunet/gnunet_mhd_compat.h> @@ -52,7 +53,7 @@ * Above what request latency do we start to log? */ #define WARN_LATENCY GNUNET_TIME_relative_multiply ( \ - GNUNET_TIME_UNIT_MILLISECONDS, 500) + GNUNET_TIME_UNIT_MILLISECONDS, 500) /** * Are clients allowed to request /keys for times other than the @@ -388,6 +389,29 @@ proceed_with_handler (struct DH_RequestContext *rc, /** + * Handle a "/charities/$CHARITY_ID" GET request. + * + * @param rc request context + * @param optional charity id (args[0]) + * @return MHD result code + */ +static MHD_RESULT +handle_get_charities (struct DH_RequestContext *rc, + const char *const args[1]) +{ + if (NULL == args[0]) + { + return DH_handler_charities_get (rc); + } + else + { + return DH_handler_charity_get (rc, + args[0]); + } +} + + +/** * Handle incoming HTTP request. * * @param cls closure for MHD daemon (unused) @@ -448,7 +472,9 @@ handle_mhd_request (void *cls, { .url = "charities", .method = MHD_HTTP_METHOD_GET, - .handler.get = &DH_handler_charities_get + .handler.get = &handle_get_charities, + .nargs = 1, + .nargs_is_upper_bound = true }, /* POST charities */ { diff --git a/src/donau/donau-httpd_charity.h b/src/donau/donau-httpd_charity.h @@ -40,7 +40,7 @@ DH_handler_charity_post ( /** - * Handle a GET "/charity" request. + * Handle a GET "/charities/$CHARITY_ID" request. * * @param rc request context * @param args GET arguments (should be one) @@ -49,7 +49,7 @@ DH_handler_charity_post ( MHD_RESULT DH_handler_charity_get ( struct DH_RequestContext *rc, - const char *const args[]); + const char *const args[1]); /** diff --git a/src/donau/donau-httpd_get-charity.c b/src/donau/donau-httpd_get-charity.c @@ -40,7 +40,7 @@ MHD_RESULT DH_handler_charity_get ( struct DH_RequestContext *rc, - const char *const args[]) + const char *const args[1]) { unsigned long long charity_id; char dummy; @@ -58,15 +58,6 @@ DH_handler_charity_get ( "charity_id"); } - if (NULL != args[1]) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_GENERIC_ENDPOINT_UNKNOWN, - args[1]); - } - { struct DONAUDB_CharityMetaData meta; enum GNUNET_DB_QueryStatus qs;