gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-donau] branch master updated: [httpd] added charities get helper


From: gnunet
Subject: [taler-donau] branch master updated: [httpd] added charities get helper
Date: Mon, 15 Jan 2024 17:55:28 +0100

This is an automated email from the git hooks/post-receive script.

johannes-casaburi pushed a commit to branch master
in repository donau.

The following commit(s) were added to refs/heads/master by this push:
     new bddae68  [httpd] added charities get helper
bddae68 is described below

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

    [httpd] added charities get helper
---
 src/donau/donau-httpd.c             | 30 ++++++++++++++++++++++++++++--
 src/donau/donau-httpd_charity.h     |  4 ++--
 src/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
index 2d58c74..bdc0985 100644
--- 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
@@ -387,6 +388,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.
  *
@@ -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
index 190438f..b682c38 100644
--- 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
index 21c0b63..f5fbec9 100644
--- 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;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]