donau

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

commit 081427c8f1e4c7e2d5315add1b69a1973e07d649
parent f49c763dba881e5b90fb46c01e7036779cd26a4b
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
Date:   Sun,  7 Jan 2024 15:03:47 +0100

added get charities route to httpd

Diffstat:
Msrc/donau/Makefile.am | 3++-
Msrc/donau/donau-httpd.c | 16++++++++++++----
Msrc/donau/donau-httpd_charity.h | 17++++++++++++++---
Msrc/donau/donau-httpd_get-charities.c | 9++++++---
4 files changed, 34 insertions(+), 11 deletions(-)

diff --git a/src/donau/Makefile.am b/src/donau/Makefile.am @@ -38,7 +38,8 @@ donau_httpd_LDADD = \ donau_httpd_SOURCES = \ donau-httpd.c donau-httpd.h \ donau-httpd_keys.c donau-httpd_keys.h \ - donau-httpd_config.c donau-httpd_config.h + donau-httpd_config.c donau-httpd_config.h \ + donau-httpd_get-charities.c donau_httpd_charity.h # Testcases diff --git a/src/donau/donau-httpd.c b/src/donau/donau-httpd.c @@ -35,6 +35,7 @@ #include "donau_util.h" #include "donau-httpd_config.h" #include "donau-httpd_keys.h" +#include "donau-httpd_charity.h" /** * Backlog for listen operation on unix domain sockets. @@ -50,7 +51,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 @@ -429,13 +430,20 @@ handle_mhd_request (void *cls, { .url = "keys", .method = MHD_HTTP_METHOD_GET, - .handler.get = &DH_keys_get_handler, - .nargs = 1 + .handler.get = &DH_keys_get_handler// , + // .nargs = 1 + }, + /* GET charities */ + { + .url = "charities", + .method = MHD_HTTP_METHOD_GET, + .handler.get = &DH_handler_charities_get }, /** etc - Add routes here + Add routes here (also make sure to add the + corresponding lines in the makefile) */ /* mark end of list */ { diff --git a/src/donau/donau-httpd_charity.h b/src/donau/donau-httpd_charity.h @@ -18,11 +18,11 @@ * @brief Handle /charity requests * @author Johannes Casaburi */ -#ifndef TALER_EXCHANGE_HTTPD_AML_DECISION_H -#define TALER_EXCHANGE_HTTPD_AML_DECISION_H +#ifndef DONAU_HTTPD_CHARITY_H +#define DONAU_HTTPD_CHARITY_H #include <microhttpd.h> -#include "donau-httpd.h" +// #include "donau-httpd.h" /** @@ -50,5 +50,16 @@ DH_handler_charity_get ( struct DH_RequestContext *rc, const char *const args[]); +/** + * Handle a GET "/charities" request. + * + * @param rc request context + * @param args GET arguments (should be one) + * @return MHD result code + */ +MHD_RESULT +DH_handler_charities_get ( + struct DH_RequestContext *rc, + const char *const args[]); #endif diff --git a/src/donau/donau-httpd_get-charities.c b/src/donau/donau-httpd_get-charities.c @@ -18,7 +18,7 @@ * @brief Return charities * @author Johannes Casaburi */ -#include "platform.h" +#include "taler/platform.h" #include <gnunet/gnunet_util_lib.h> #include <jansson.h> #include <microhttpd.h> @@ -43,7 +43,10 @@ * @param cls closure */ static void -charities_cb (void *cls) +charities_cb ( + void *cls, + const char *charity_url, + const char *charity_name) { json_t *charities = cls; @@ -62,7 +65,7 @@ charities_cb (void *cls) MHD_RESULT DH_handler_charities_get ( - struct TEH_RequestContext *rc, + struct DH_RequestContext *rc, const char *const args[]) {