diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-04-09 14:55:12 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-04-09 14:55:12 +0200 |
commit | 89a3d27ef5b92eb3a2aea758e49ad138422a1df0 (patch) | |
tree | 2aaebcc1ae5dfcd0a02b7e67d0cc784f8ef3b962 /src | |
parent | 4f8cb89a52858d646e1355f9c1c4f97ee77a4365 (diff) | |
download | merchant-89a3d27ef5b92eb3a2aea758e49ad138422a1df0.tar.gz merchant-89a3d27ef5b92eb3a2aea758e49ad138422a1df0.tar.bz2 merchant-89a3d27ef5b92eb3a2aea758e49ad138422a1df0.zip |
fix /config part of #6838
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/taler-merchant-httpd.c | 42 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd.h | 5 |
2 files changed, 24 insertions, 23 deletions
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c index 0878b265..041162b4 100644 --- a/src/backend/taler-merchant-httpd.c +++ b/src/backend/taler-merchant-httpd.c @@ -1110,22 +1110,20 @@ url_handler (void *cls, void **con_cls) { static struct TMH_RequestHandler private_handlers[] = { - /* GET /instances; MUST be at the beginning of the - array, as this endpoint ONLY applies to the - default instance! See use_default logic below. */ + /* GET /instances */ { .url_prefix = "/instances", .method = MHD_HTTP_METHOD_GET, .skip_instance = true, + .default_only = true, .handler = &TMH_private_get_instances }, - /* POST /instances; MUST be at the beginning of the - array, as this endpoint ONLY applies to the - default instance! See use_default logic below. */ + /* POST /instances */ { .url_prefix = "/instances", .method = MHD_HTTP_METHOD_POST, .skip_instance = true, + .default_only = true, .handler = &TMH_private_post_instances, /* allow instance data of up to 8 MB, that should be plenty; note that exceeding #GNUNET_MAX_MALLOC_CHECKED (40 MB) @@ -1133,30 +1131,27 @@ url_handler (void *cls, in the code... */ .max_upload = 1024 * 1024 * 8 }, - /* GET /instances/$ID/: MUST be at the beginning of the - array, as this endpoint ONLY applies to the - default instance! See use_default logic below. */ + /* GET /instances/$ID/ */ { .url_prefix = "/instances/", .method = MHD_HTTP_METHOD_GET, + .default_only = true, .have_id_segment = true, .handler = &TMH_private_get_instances_default_ID }, - /* DELETE /private/instances/$ID: MUST be at the beginning of the - array, as this endpoint ONLY applies to the - default instance! See use_default logic below. */ + /* DELETE /private/instances/$ID */ { .url_prefix = "/instances/", .method = MHD_HTTP_METHOD_DELETE, + .default_only = true, .have_id_segment = true, .handler = &TMH_private_delete_instances_default_ID }, - /* PATCH /instances/$ID/: MUST be at the beginning of the - array, as this endpoint ONLY applies to the - default instance! See use_default logic below.*/ + /* PATCH /instances/$ID/ */ { .url_prefix = "/instances/", .method = MHD_HTTP_METHOD_PATCH, + .default_only = true, .have_id_segment = true, .handler = &TMH_private_patch_instances_default_ID, /* allow instance data of up to 8 MB, that should be plenty; @@ -1165,20 +1160,18 @@ url_handler (void *cls, in the code... */ .max_upload = 1024 * 1024 * 8 }, - /* POST /auth: MUST be at the beginning of the - array, as this endpoint ONLY applies to the - default instance! See use_default logic below.*/ + /* POST /auth: */ { .url_prefix = "/instances/", .url_suffix = "auth", .method = MHD_HTTP_METHOD_POST, + .default_only = true, .have_id_segment = true, .handler = &TMH_private_post_instances_default_ID_auth, /* Body should be pretty small. */ .max_upload = 1024 * 1024, }, - /* **** End of array entries specific to default instance **** */ /* GET /instances/$ID/: */ { .url_prefix = "/", @@ -1436,6 +1429,7 @@ url_handler (void *cls, .url_prefix = "/config", .method = MHD_HTTP_METHOD_GET, .skip_instance = true, + .default_only = true, .handler = &MH_handler_config }, /* Also serve the same /config per instance */ @@ -1443,6 +1437,7 @@ url_handler (void *cls, .url_prefix = "/config", .method = MHD_HTTP_METHOD_GET, .skip_instance = false, + .allow_deleted_instance = true, .handler = &MH_handler_config }, /* POST /orders/$ID/abort: */ @@ -1685,10 +1680,7 @@ url_handler (void *cls, (0 == strcmp (url, "/private")) ) { - if (use_default) - handlers = private_handlers; - else - handlers = &private_handlers[6]; /* skip first six methods: default instance-only! */ + handlers = private_handlers; url += strlen (private_prefix) - 1; use_private = true; } @@ -1745,6 +1737,8 @@ url_handler (void *cls, { struct TMH_RequestHandler *rh = &handlers[i]; + if (rh->default_only && (! use_default)) + continue; if (! prefix_match (rh, url, prefix_strlen, @@ -1780,6 +1774,8 @@ url_handler (void *cls, { struct TMH_RequestHandler *rh = &handlers[i]; + if (rh->default_only && (! use_default)) + continue; if (! prefix_match (rh, url, prefix_strlen, diff --git a/src/backend/taler-merchant-httpd.h b/src/backend/taler-merchant-httpd.h index 7f42e107..4144d648 100644 --- a/src/backend/taler-merchant-httpd.h +++ b/src/backend/taler-merchant-httpd.h @@ -203,6 +203,11 @@ struct TMH_RequestHandler bool skip_instance; /** + * Does this endpoint ONLY apply for the default instance? + */ + bool default_only; + + /** * Does this request handler work with a deleted instance? */ bool allow_deleted_instance; |