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.c62
1 files changed, 55 insertions, 7 deletions
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c
index d97c68e3..32cbd8dd 100644
--- a/src/exchange/taler-exchange-httpd.c
+++ b/src/exchange/taler-exchange-httpd.c
@@ -1070,18 +1070,32 @@ handle_get_extensions (struct TEH_RequestContext *rc,
"/extensions/$EXTENSION unknown");
}
- if (NULL == ext->http_get_handler)
+ 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->http_get_handler (
+ 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.
*
@@ -1096,6 +1110,7 @@ handle_post_extensions (struct TEH_RequestContext *rc,
const char *const args[])
{
const struct TALER_Extension *ext = NULL;
+ json_t *output;
if (NULL == args[0])
{
@@ -1112,16 +1127,49 @@ handle_post_extensions (struct TEH_RequestContext *rc,
"/extensions/$EXTENSION unknown");
}
- if (NULL == ext->http_post_handler)
+ 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");
- return ext->http_post_handler (
- rc->connection,
- root,
- &args[1]);
+ {
+ 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);
}