diff options
-rw-r--r-- | src/backend/Makefile.am | 2 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd.c | 47 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-categories.c | 6 |
3 files changed, 50 insertions, 5 deletions
diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am index 60ebee32..cce7faec 100644 --- a/src/backend/Makefile.am +++ b/src/backend/Makefile.am @@ -119,6 +119,8 @@ taler_merchant_httpd_SOURCES = \ taler-merchant-httpd_private-patch-webhooks-ID.h \ taler-merchant-httpd_private-post-account.c \ taler-merchant-httpd_private-post-account.h \ + taler-merchant-httpd_private-post-categories.c \ + taler-merchant-httpd_private-post-categories.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 0fa83d81..e9ee1cbf 100644 --- a/src/backend/taler-merchant-httpd.c +++ b/src/backend/taler-merchant-httpd.c @@ -34,6 +34,7 @@ #include "taler-merchant-httpd_get-templates-ID.h" #include "taler-merchant-httpd_mhd.h" #include "taler-merchant-httpd_private-delete-account-ID.h" +#include "taler-merchant-httpd_private-delete-categories-ID.h" #include "taler-merchant-httpd_private-delete-instances-ID.h" #include "taler-merchant-httpd_private-delete-instances-ID-token.h" #include "taler-merchant-httpd_private-delete-products-ID.h" @@ -45,6 +46,8 @@ #include "taler-merchant-httpd_private-delete-webhooks-ID.h" #include "taler-merchant-httpd_private-get-accounts.h" #include "taler-merchant-httpd_private-get-accounts-ID.h" +#include "taler-merchant-httpd_private-get-categories.h" +#include "taler-merchant-httpd_private-get-categories-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-instances-ID-kyc.h" @@ -63,6 +66,7 @@ #include "taler-merchant-httpd_private-get-webhooks.h" #include "taler-merchant-httpd_private-get-webhooks-ID.h" #include "taler-merchant-httpd_private-patch-accounts-ID.h" +#include "taler-merchant-httpd_private-patch-categories-ID.h" #include "taler-merchant-httpd_private-patch-instances-ID.h" #include "taler-merchant-httpd_private-patch-orders-ID-forget.h" #include "taler-merchant-httpd_private-patch-otp-devices-ID.h" @@ -71,6 +75,7 @@ #include "taler-merchant-httpd_private-patch-token-families-SLUG.h" #include "taler-merchant-httpd_private-patch-webhooks-ID.h" #include "taler-merchant-httpd_private-post-account.h" +#include "taler-merchant-httpd_private-post-categories.h" #include "taler-merchant-httpd_private-post-instances.h" #include "taler-merchant-httpd_private-post-instances-ID-auth.h" #include "taler-merchant-httpd_private-post-instances-ID-token.h" @@ -939,6 +944,46 @@ url_handler (void *cls, .method = MHD_HTTP_METHOD_GET, .handler = &TMH_private_get_pos }, + /* GET /categories: */ + { + .url_prefix = "/categories", + .method = MHD_HTTP_METHOD_GET, + .handler = &TMH_private_get_categories + }, + /* POST /categories: */ + { + .url_prefix = "/categories", + .method = MHD_HTTP_METHOD_POST, + .handler = &TMH_private_post_categories, + /* allow category data of up to 8 kb, that should be plenty */ + .max_upload = 1024 * 8 + }, + /* GET /categories/$ID: */ + { + .url_prefix = "/categories/", + .method = MHD_HTTP_METHOD_GET, + .have_id_segment = true, + .allow_deleted_instance = true, + .handler = &TMH_private_get_categories_ID + }, + /* DELETE /categories/$ID: */ + { + .url_prefix = "/categories/", + .method = MHD_HTTP_METHOD_DELETE, + .have_id_segment = true, + .allow_deleted_instance = true, + .handler = &TMH_private_delete_categories_ID + }, + /* PATCH /categories/$ID/: */ + { + .url_prefix = "/categories/", + .method = MHD_HTTP_METHOD_PATCH, + .have_id_segment = true, + .allow_deleted_instance = true, + .handler = &TMH_private_patch_categories_ID, + /* allow category data of up to 8 kb, that should be plenty */ + .max_upload = 1024 * 8 + }, /* GET /products: */ { .url_prefix = "/products", @@ -956,7 +1001,7 @@ url_handler (void *cls, in the code... */ .max_upload = 1024 * 1024 * 8 }, - /* GET /products/$ID/: */ + /* GET /products/$ID: */ { .url_prefix = "/products/", .method = MHD_HTTP_METHOD_GET, diff --git a/src/backend/taler-merchant-httpd_private-post-categories.c b/src/backend/taler-merchant-httpd_private-post-categories.c index 9e708724..675de765 100644 --- a/src/backend/taler-merchant-httpd_private-post-categories.c +++ b/src/backend/taler-merchant-httpd_private-post-categories.c @@ -110,10 +110,8 @@ TMH_private_post_categories (const struct TMH_RequestHandler *rh, { bool eq; - eq = ( (0 == strcmp (cd.category_name, - category_name)) && - (1 == json_equal (xcategory_name_i18n, - category_name_i18n)) ); + eq = (1 == json_equal (xcategory_name_i18n, + category_name_i18n)); json_decref (xcategory_name_i18n); TMH_db->rollback (TMH_db->cls); GNUNET_JSON_parse_free (spec); |