commit dc8df52d1dc59ff1550757503b9a3e625da5a2a3
parent e8dcc2f7c60c6e0fc734810b1d675c86f72132b5
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
Date: Tue, 9 Jan 2024 12:50:22 +0100
[httpd] added post route
Diffstat:
3 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/src/donau/donau-httpd.c b/src/donau/donau-httpd.c
@@ -52,7 +52,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
@@ -451,6 +451,12 @@ handle_mhd_request (void *cls,
.method = MHD_HTTP_METHOD_GET,
.handler.get = &DH_handler_charities_get
},
+ /* POST charities */
+ {
+ .url = "charities",
+ .method = MHD_HTTP_METHOD_POST,
+ .handler.post = &DH_handler_charity_post
+ },
/**
etc
diff --git a/src/donau/donau-httpd_charity.h b/src/donau/donau-httpd_charity.h
@@ -33,9 +33,10 @@
* @return MHD result code
*/
MHD_RESULT
-TEH_handler_charity_post (
- struct MHD_Connection *connection,
- const json_t *root);
+DH_handler_charity_post (
+ struct DH_RequestContext *rc,
+ const json_t *root,
+ const char *const args[]);
/**
diff --git a/src/donau/donau-httpd_post-charity.c b/src/donau/donau-httpd_post-charity.c
@@ -96,9 +96,9 @@ insert_charity (void *cls,
MHD_RESULT
-DH_handler_charity_post (
- struct MHD_Connection *connection,
- const json_t *root)
+DH_handler_charity_post (struct DH_RequestContext *rc,
+ const json_t *root,
+ const char *const args[])
{
struct InsertCharityContext icc;
@@ -113,7 +113,7 @@ DH_handler_charity_post (
{
enum GNUNET_GenericReturnValue res;
- res = TALER_MHD_parse_json_data (connection,
+ res = TALER_MHD_parse_json_data (rc->connection,
root,
spec);
if (GNUNET_SYSERR == res)
@@ -129,7 +129,7 @@ DH_handler_charity_post (
MHD_RESULT mhd_ret;
if (GNUNET_OK !=
- DH_DB_run_transaction (connection,
+ DH_DB_run_transaction (rc->connection,
"insert_charity",
DH_MT_REQUEST_OTHER,
&mhd_ret,
@@ -140,7 +140,7 @@ DH_handler_charity_post (
}
}
return TALER_MHD_reply_static (
- connection,
+ rc->connection,
MHD_HTTP_NO_CONTENT,
NULL,
NULL,