summaryrefslogtreecommitdiff
path: root/src/exchange/taler-exchange-httpd.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-02-26 17:00:41 +0100
committerChristian Grothoff <christian@grothoff.org>2020-02-26 17:00:41 +0100
commitfb9324338d9580b520b3713bf973bfcd9c49b569 (patch)
treeaa90b29dbad21957c864834895fe6b00272a058f /src/exchange/taler-exchange-httpd.h
parent30b24448c8250b01eba8368f38c9ccdc2075f903 (diff)
downloadexchange-fb9324338d9580b520b3713bf973bfcd9c49b569.tar.gz
exchange-fb9324338d9580b520b3713bf973bfcd9c49b569.tar.bz2
exchange-fb9324338d9580b520b3713bf973bfcd9c49b569.zip
phase 1 of #6067: update exchange HTTPD to new API style
Diffstat (limited to 'src/exchange/taler-exchange-httpd.h')
-rw-r--r--src/exchange/taler-exchange-httpd.h74
1 files changed, 51 insertions, 23 deletions
diff --git a/src/exchange/taler-exchange-httpd.h b/src/exchange/taler-exchange-httpd.h
index 38c611c66..8489d1790 100644
--- a/src/exchange/taler-exchange-httpd.h
+++ b/src/exchange/taler-exchange-httpd.h
@@ -24,6 +24,8 @@
#define TALER_EXCHANGE_HTTPD_H
#include <microhttpd.h>
+#include "taler_json_lib.h"
+#include "taler_crypto_lib.h"
/**
@@ -65,51 +67,77 @@ struct TEH_RequestHandler
{
/**
- * URL the handler is for.
+ * URL the handler is for (first part only).
*/
const char *url;
/**
- * Method the handler is for, NULL for "all".
+ * Method the handler is for.
*/
const char *method;
/**
+ * Callbacks for handling of the request. Which one is used
+ * depends on @e method.
+ */
+ union
+ {
+ /**
+ * Function to call to handle a GET requests (and those
+ * with @e method NULL).
+ *
+ * @param rh this struct
+ * @param mime_type the @e mime_type for the reply (hint, can be NULL)
+ * @param connection the MHD connection to handle
+ * @param args array of arguments, needs to be of length @e args_expected
+ * @return MHD result code
+ */
+ int (*get)(const struct TEH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ const char *const args[]);
+
+
+ /**
+ * Function to call to handle a POST request.
+ *
+ * @param rh this struct
+ * @param mime_type the @e mime_type for the reply (hint, can be NULL)
+ * @param connection the MHD connection to handle
+ * @param json uploaded JSON data
+ * @param args array of arguments, needs to be of length @e args_expected
+ * @return MHD result code
+ */
+ int (*post)(const struct TEH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ const json_t *root,
+ const char *const args[]);
+
+ } handler;
+
+ /**
+ * Number of arguments this handler expects in the @a args array.
+ */
+ unsigned int nargs;
+
+ /**
* Mime type to use in reply (hint, can be NULL).
*/
const char *mime_type;
/**
- * Raw data for the @e handler
+ * Raw data for the @e handler, can be NULL for none provided.
*/
const void *data;
/**
- * Number of bytes in @e data, 0 for 0-terminated.
+ * Number of bytes in @e data, 0 for data is 0-terminated (!).
*/
size_t data_size;
/**
- * Function to call to handle the request.
- *
- * @param rh this struct
- * @param mime_type the @e mime_type for the reply (hint, can be NULL)
- * @param connection the MHD connection to handle
- * @param[in,out] connection_cls the connection's closure (can be updated)
- * @param upload_data upload data
- * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
- * @return MHD result code
- */
- int (*handler)(struct TEH_RequestHandler *rh,
- struct MHD_Connection *connection,
- void **connection_cls,
- const char *upload_data,
- size_t *upload_data_size);
-
- /**
- * Default response code.
+ * Default response code. 0 for none provided.
*/
- int response_code;
+ unsigned int response_code;
};