taler-merchant-httpd_private-delete-token-families-SLUG.c (2871B)
1 /* 2 This file is part of TALER 3 (C) 2023 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU Affero General Public License as published by the Free Software 7 Foundation; either version 3, or (at your option) any later version. 8 9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License along with 14 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file taler-merchant-httpd_private-delete-token-families-SLUG.c 18 * @brief implement DELETE /tokenfamilies/$SLUG 19 * @author Christian Blättler 20 */ 21 #include "platform.h" 22 #include "taler-merchant-httpd_private-delete-token-families-SLUG.h" 23 #include <gnunet/gnunet_db_lib.h> 24 #include <taler/taler_json_lib.h> 25 26 27 /** 28 * Handle a DELETE "/tokenfamilies/$SLUG" request. 29 * 30 * @param rh context of the handler 31 * @param connection the MHD connection to handle 32 * @param[in,out] hc context with further information about the request 33 * @return MHD result code 34 */ 35 MHD_RESULT 36 TMH_private_delete_token_families_SLUG (const struct TMH_RequestHandler *rh, 37 struct MHD_Connection *connection, 38 struct TMH_HandlerContext *hc) 39 { 40 struct TMH_MerchantInstance *mi = hc->instance; 41 enum GNUNET_DB_QueryStatus qs; 42 43 (void) rh; 44 GNUNET_assert (NULL != mi); 45 GNUNET_assert (NULL != hc->infix); 46 qs = TMH_db->delete_token_family (TMH_db->cls, 47 mi->settings.id, 48 hc->infix); 49 switch (qs) 50 { 51 case GNUNET_DB_STATUS_HARD_ERROR: 52 return TALER_MHD_reply_with_error (connection, 53 MHD_HTTP_INTERNAL_SERVER_ERROR, 54 TALER_EC_GENERIC_DB_STORE_FAILED, 55 "delete_token_family"); 56 case GNUNET_DB_STATUS_SOFT_ERROR: 57 GNUNET_break (0); 58 return TALER_MHD_reply_with_error (connection, 59 MHD_HTTP_INTERNAL_SERVER_ERROR, 60 TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, 61 "delete_token_family (soft)"); 62 case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: 63 case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: 64 return TALER_MHD_reply_static (connection, 65 MHD_HTTP_NO_CONTENT, 66 NULL, 67 NULL, 68 0); 69 } 70 GNUNET_assert (0); 71 return MHD_NO; 72 } 73 74 75 /* end of taler-merchant-httpd_private-delete-token-families-SLUG.c */