summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorpriscilla <priscilla.huang@efrei.net>2022-11-21 11:31:44 -0500
committerpriscilla <priscilla.huang@efrei.net>2022-11-22 08:14:50 -0500
commitae6d2de1610ceb06e58b945a04a3d184b95d3e44 (patch)
tree8e2a7640b7b2e4e9de5f6f706a93bc7f94e0d54c /src/backend
parent01939fd2f0bf4f6ef3fa1c44b6ff39a981613259 (diff)
downloadmerchant-ae6d2de1610ceb06e58b945a04a3d184b95d3e44.tar.gz
merchant-ae6d2de1610ceb06e58b945a04a3d184b95d3e44.tar.bz2
merchant-ae6d2de1610ceb06e58b945a04a3d184b95d3e44.zip
update
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/Makefile.am10
-rw-r--r--src/backend/taler-merchant-httpd.c46
-rw-r--r--src/backend/taler-merchant-httpd_private-get-templates-ID.c3
-rw-r--r--src/backend/taler-merchant-httpd_private-get-templates.c3
4 files changed, 60 insertions, 2 deletions
diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am
index 2bd25251..a24e80ad 100644
--- 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
index 67359ece..631f4e1a 100644
--- 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
index 80fccd40..c9f64ae5 100644
--- 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
index 20cd0cdc..fe5d729f 100644
--- 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;