aboutsummaryrefslogtreecommitdiff
path: root/src/exchange/taler-exchange-httpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchange/taler-exchange-httpd.c')
-rw-r--r--src/exchange/taler-exchange-httpd.c141
1 files changed, 1 insertions, 140 deletions
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c
index 32cbd8dd..1cbaee96 100644
--- a/src/exchange/taler-exchange-httpd.c
+++ b/src/exchange/taler-exchange-httpd.c
@@ -1041,138 +1041,6 @@ handle_post_auditors (struct TEH_RequestContext *rc,
root);
}
-
-/**
- * Handle GET "/extensions/..." requests.
- *
- * @param rc request context
- * @param args array of additional options
- * @return MHD result code
- */
-static MHD_RESULT
-handle_get_extensions (struct TEH_RequestContext *rc,
- const char *const args[])
-{
- const struct TALER_Extension *ext = NULL;
-
- if (NULL == args[0])
- {
- GNUNET_break_op (0);
- return r404 (rc->connection,
- "/extensions/$EXTENSION");
- }
-
- ext = TALER_extensions_get_by_name (args[0]);
- if (NULL == ext)
- {
- GNUNET_break_op (0);
- return r404 (rc->connection,
- "/extensions/$EXTENSION unknown");
- }
-
- if (NULL == ext->policy_get_handler)
- return TALER_MHD_reply_with_error (rc->connection,
- MHD_HTTP_NOT_IMPLEMENTED,
- TALER_EC_EXCHANGE_GENERIC_OPERATION_UNKNOWN,
- "GET /extensions/$EXTENSION not supported");
-
- return ext->policy_get_handler (
- rc->connection,
- &args[1]);
-}
-
-
-/* @brief function pointer for TALER_extension.check */
-static enum GNUNET_GenericReturnValue
-check_serial_ids (
- struct GNUNET_HashCode serial_ids[],
- size_t size)
-{
- for (size_t i = 0; i < size; i++)
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Got to check serial_id: %s\n",
- GNUNET_h2s (&serial_ids[i]));
- return GNUNET_OK;
-}
-
-
-/**
- * Handle POST "/extensions/..." requests.
- *
- * @param rc request context
- * @param root uploaded JSON data
- * @param args array of additional options
- * @return MHD result code
- */
-static MHD_RESULT
-handle_post_extensions (struct TEH_RequestContext *rc,
- const json_t *root,
- const char *const args[])
-{
- const struct TALER_Extension *ext = NULL;
- json_t *output;
-
- if (NULL == args[0])
- {
- GNUNET_break_op (0);
- return r404 (rc->connection,
- "/extensions/$EXTENSION");
- }
-
- ext = TALER_extensions_get_by_name (args[0]);
- if (NULL == ext)
- {
- GNUNET_break_op (0);
- return r404 (rc->connection,
- "/extensions/$EXTENSION unknown");
- }
-
- if (NULL == ext->policy_post_handler)
- return TALER_MHD_reply_with_error (rc->connection,
- MHD_HTTP_NOT_IMPLEMENTED,
- TALER_EC_EXCHANGE_GENERIC_OPERATION_UNKNOWN,
- "POST /extensions/$EXTENSION not supported");
-
- {
- enum GNUNET_GenericReturnValue ret;
- struct TALER_PolicyFulfilmentOutcome *outcome;
-
- ret = ext->policy_post_handler (root,
- &args[1],
- &check_serial_ids,
- &outcome,
- &output);
-
- if (GNUNET_OK != ret)
- {
- TALER_policy_fulfilment_outcome_free (outcome);
- TALER_MHD_reply_json_steal (
- rc->connection,
- output,
- MHD_HTTP_BAD_REQUEST);
- }
-
- /* TODO: deal with outcome */
- {
- for (size_t i = 0; i < outcome->len; i++)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Got outcome for serial_id: %s, state: %s, amount: %s\n",
- GNUNET_h2s (&outcome->positions[i].serial_id),
- TALER_policy_fulfilment_state_str (
- outcome->positions[i].state),
- TALER_amount_to_string (&outcome->positions[i].new_amount));
- }
- }
-
- }
-
- return TALER_MHD_reply_json_steal (rc->connection,
- output,
- MHD_HTTP_OK);
-}
-
-
/**
* Handle incoming HTTP request.
*
@@ -1393,15 +1261,8 @@ handle_mhd_request (void *cls,
/* extensions endpoints */
{
.url = "extensions",
- .method = MHD_HTTP_METHOD_GET,
- .handler.get = &handle_get_extensions,
- .nargs = 4, /* Arbitrary upper bound */
- .nargs_is_upper_bound = true,
- },
- {
- .url = "extensions",
.method = MHD_HTTP_METHOD_POST,
- .handler.post = &handle_post_extensions,
+ .handler.post = &TEH_extensions_post_handler,
.nargs = 4, /* Arbitrary upper bound */
.nargs_is_upper_bound = true,
},