merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit ae6d2de1610ceb06e58b945a04a3d184b95d3e44
parent 01939fd2f0bf4f6ef3fa1c44b6ff39a981613259
Author: priscilla <priscilla.huang@efrei.net>
Date:   Mon, 21 Nov 2022 11:31:44 -0500

update

Diffstat:
Msrc/backend/Makefile.am | 10++++++++++
Msrc/backend/taler-merchant-httpd.c | 46++++++++++++++++++++++++++++++++++++++++++++++
Msrc/backend/taler-merchant-httpd_private-get-templates-ID.c | 3++-
Msrc/backend/taler-merchant-httpd_private-get-templates.c | 3++-
4 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am @@ -34,6 +34,8 @@ taler_merchant_httpd_SOURCES = \ taler-merchant-httpd_private-get-tips-ID.c \ taler-merchant-httpd_private-get-tips-ID.h \ taler-merchant-httpd_mhd.c taler-merchant-httpd_mhd.h \ + taler-merchant-httpd_private-delete-templates-ID.c \ + taler-merchant-httpd_private-delete-templates-ID.h \ taler-merchant-httpd_private-delete-instances-ID.c \ taler-merchant-httpd_private-delete-instances-ID.h \ taler-merchant-httpd_private-delete-products-ID.c \ @@ -64,12 +66,20 @@ taler_merchant_httpd_SOURCES = \ taler-merchant-httpd_private-get-reserves-ID.h \ taler-merchant-httpd_private-get-transfers.c \ taler-merchant-httpd_private-get-transfers.h \ + taler-merchant-httpd_private-get-templates.c \ + taler-merchant-httpd_private-get-templates.h \ + taler-merchant-httpd_private-get-templates-ID.c \ + taler-merchant-httpd_private-get-templates-ID.h \ + taler-merchant-httpd_private-patch-templates-ID.c \ + taler-merchant-httpd_private-patch-templates-ID.h \ taler-merchant-httpd_private-patch-instances-ID.c \ taler-merchant-httpd_private-patch-instances-ID.h \ taler-merchant-httpd_private-patch-orders-ID-forget.c \ taler-merchant-httpd_private-patch-orders-ID-forget.h \ taler-merchant-httpd_private-patch-products-ID.c \ taler-merchant-httpd_private-patch-products-ID.h \ + taler-merchant-httpd_private-post-templates.c \ + taler-merchant-httpd_private-post-templates.h \ taler-merchant-httpd_private-post-instances.c \ taler-merchant-httpd_private-post-instances.h \ taler-merchant-httpd_private-post-instances-ID-auth.c \ diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c @@ -1056,6 +1056,52 @@ url_handler (void *cls, .method = MHD_HTTP_METHOD_OPTIONS, .handler = &handle_server_options }, + /* GET /templates: */ + { + .url_prefix = "/templates/", + .method = MHD_HTTP_METHOD_GET, + .handler = &TMH_private_get_templates + }, + /* POST /templates: */ + { + .url_prefix = "/templates/", + .method = MHD_HTTP_METHOD_POST, + .handler = &TMH_private_post_templates, + /* allow template data of up to 8 MB, that should be plenty; + note that exceeding #GNUNET_MAX_MALLOC_CHECKED (40 MB) + would require further changes to the allocation logic + in the code... */ + .max_upload = 1024 * 1024 * 8 + }, + /* GET /templates/$ID/: */ + { + .url_prefix = "/templates/", + .method = MHD_HTTP_METHOD_GET, + .have_id_segment = true, + .allow_deleted_instance = true, + .handler = &TMH_private_get_templates_ID + }, + /* DELETE /templates/$ID/: */ + { + .url_prefix = "/templates/", + .method = MHD_HTTP_METHOD_DELETE, + .have_id_segment = true, + .allow_deleted_instance = true, + .handler = &TMH_private_delete_templates_ID + }, + /* PATCH /templates/$ID/: */ + { + .url_prefix = "/templates/", + .method = MHD_HTTP_METHOD_PATCH, + .have_id_segment = true, + .allow_deleted_instance = true, + .handler = &TMH_private_patch_templates_ID, + /* allow template data of up to 8 MB, that should be plenty; + note that exceeding #GNUNET_MAX_MALLOC_CHECKED (40 MB) + would require further changes to the allocation logic + in the code... */ + .max_upload = 1024 * 1024 * 8 + }, { .url_prefix = NULL } diff --git a/src/backend/taler-merchant-httpd_private-get-templates-ID.c b/src/backend/taler-merchant-httpd_private-get-templates-ID.c @@ -71,9 +71,10 @@ TMH_private_get_templates_ID (const struct TMH_RequestHandler *rh, GNUNET_JSON_pack_string ("image", tp.image), GNUNET_JSON_pack_object_steal ("template_contract", - tp.template_contract), + tp.template_contract)); GNUNET_free (tp.template_description); GNUNET_free (tp.image); + return ret; } } diff --git a/src/backend/taler-merchant-httpd_private-get-templates.c b/src/backend/taler-merchant-httpd_private-get-templates.c @@ -30,7 +30,8 @@ */ static void add_template (void *cls, - const char *template_id) + const char *template_id, + const char *template_description) { json_t *pa = cls;