summaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-05-20 17:20:40 +0200
committerChristian Grothoff <christian@grothoff.org>2020-05-20 17:20:40 +0200
commit3d6cce7434847d925b51d1600f0eef79041c6591 (patch)
treeb7deb3034d6e1c8d74839499bbd1ff5c30d8b23d /src/backend/taler-merchant-httpd.c
parent74913ffcfd4e4b1de17c4eeda14601bf1f3c1561 (diff)
downloadmerchant-3d6cce7434847d925b51d1600f0eef79041c6591.tar.gz
merchant-3d6cce7434847d925b51d1600f0eef79041c6591.tar.bz2
merchant-3d6cce7434847d925b51d1600f0eef79041c6591.zip
implement reserve deletion
Diffstat (limited to 'src/backend/taler-merchant-httpd.c')
-rw-r--r--src/backend/taler-merchant-httpd.c68
1 files changed, 55 insertions, 13 deletions
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c
index 32732bd9..7f063909 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -32,6 +32,7 @@
#include "taler-merchant-httpd_private-delete-instances-ID.h"
#include "taler-merchant-httpd_private-delete-products-ID.h"
#include "taler-merchant-httpd_private-delete-orders-ID.h"
+#include "taler-merchant-httpd_private-delete-reserves-ID.h"
#include "taler-merchant-httpd_private-get-instances.h"
#include "taler-merchant-httpd_private-get-instances-ID.h"
#include "taler-merchant-httpd_private-get-products.h"
@@ -48,6 +49,7 @@
#include "taler-merchant-httpd_private-post-products.h"
#include "taler-merchant-httpd_private-post-products-ID-lock.h"
#include "taler-merchant-httpd_private-post-reserves.h"
+#include "taler-merchant-httpd_private-post-reserves-ID-authorize-tip.h"
#include "taler-merchant-httpd_private-post-transfers.h"
#include "taler-merchant-httpd_post-orders-ID-abort.h"
#include "taler-merchant-httpd_post-orders-ID-claim.h"
@@ -841,6 +843,28 @@ url_handler (void *cls,
.method = MHD_HTTP_METHOD_POST,
.handler = &TMH_private_post_reserves
},
+ /* DELETE /reserves/$ID: */
+ {
+ .url_prefix = "/reserves",
+ .have_id_segment = true,
+ .method = MHD_HTTP_METHOD_DELETE,
+ .handler = &TMH_private_delete_reserves_ID
+ },
+ /* POST /reserves/$ID/authorize-tip: */
+ {
+ .url_prefix = "/reserves",
+ .url_suffix = "authorize-tip",
+ .have_id_segment = true,
+ .method = MHD_HTTP_METHOD_POST,
+ .handler = &TMH_private_post_reserves_ID_authorize_tip
+ },
+ /* POST /reserves/authorize-tip: */
+ {
+ .url_prefix = "/reserves",
+ .url_suffix = "authorize-tip",
+ .method = MHD_HTTP_METHOD_POST,
+ .handler = &TMH_private_post_reserves_authorize_tip
+ },
/* GET /reserves: */
{
.url_prefix = "/reserves",
@@ -1111,18 +1135,35 @@ url_handler (void *cls,
rh->url_prefix,
prefix_strlen)) )
continue;
- if ( (NULL == infix_url)
- ^ (GNUNET_NO == rh->have_id_segment) )
- continue; /* infix existence missmatch */
- if ( ( (NULL == suffix_url)
- ^ (NULL == rh->url_suffix) ) )
- continue; /* suffix existence missmatch */
- if ( (NULL != suffix_url) &&
- ( (suffix_strlen != strlen (rh->url_suffix)) ||
- (0 != memcmp (suffix_url,
- rh->url_suffix,
- suffix_strlen)) ) )
- continue; /* suffix content missmatch */
+ if (GNUNET_NO == rh->have_id_segment)
+ {
+ if (NULL != suffix_url)
+ continue; /* too many segments to match */
+ if ( (NULL == infix_url)
+ ^ (NULL == rh->url_suffix) )
+ continue; /* suffix existence missmatch */
+ if ( (NULL != infix_url) &&
+ ( (infix_strlen != strlen (rh->url_suffix)) ||
+ (0 != memcmp (infix_url,
+ rh->url_suffix,
+ infix_strlen)) ) )
+ continue; /* cannot use infix as suffix: content missmatch */
+ }
+ else
+ {
+ if ( (NULL == infix_url)
+ ^ (GNUNET_NO == rh->have_id_segment) )
+ continue; /* infix existence missmatch */
+ if ( ( (NULL == suffix_url)
+ ^ (NULL == rh->url_suffix) ) )
+ continue; /* suffix existence missmatch */
+ if ( (NULL != suffix_url) &&
+ ( (suffix_strlen != strlen (rh->url_suffix)) ||
+ (0 != memcmp (suffix_url,
+ rh->url_suffix,
+ suffix_strlen)) ) )
+ continue; /* suffix content missmatch */
+ }
url_found = true;
if (0 == strcasecmp (method,
MHD_HTTP_METHOD_OPTIONS))
@@ -1130,7 +1171,8 @@ url_handler (void *cls,
return TALER_MHD_reply_cors_preflight (connection);
}
if ( (rh->method != NULL) &&
- (0 != strcasecmp (method, rh->method)) )
+ (0 != strcasecmp (method,
+ rh->method)) )
continue;
hc->rh = rh;
break;