frosix-httpd_dkg-key_delete.c (2611B)
1 /* 2 This file is part of Frosix 3 Copyright (C) 2022, 2023 Joel Urech 4 5 Frosix 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 Frosix 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 Affero General Public License for more details. 12 13 You should have received a copy of the GNU Affero General Public License along with 14 Frosix; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file backend/frosix-httpd_key.c 18 * @brief functions to handle incoming requests on /key 19 * @author Joel Urech 20 */ 21 #include "frosix-httpd_dkg.h" 22 #include "frosix-httpd.h" 23 #include "frosix-httpd_mhd.h" 24 #include "frosix_database_plugin.h" 25 #include <taler/taler_util.h> 26 #include <gnunet/gnunet_util_lib.h> 27 #include <gnunet/gnunet_db_lib.h> 28 #include "gnunet/gnunet_curl_lib.h" 29 30 struct KeyDeleteContext 31 { 32 /** 33 * Our handler context 34 */ 35 struct TM_HandlerContext *hc; 36 37 /** 38 * Post parser context. 39 */ 40 void *post_ctx; 41 42 /** 43 * Connection handle for closing or resuming 44 */ 45 struct MHD_Connection *connection; 46 47 /** 48 * When should this request time out? 49 */ 50 struct GNUNET_TIME_Absolute timeout; 51 }; 52 53 54 MHD_RESULT 55 FH_handler_key_delete ( 56 struct MHD_Connection *connection, 57 struct TM_HandlerContext *hc, 58 const struct FROSIX_DkgRequestIdP *id) 59 { 60 struct KeyDeleteContext *dc = hc->ctx; 61 62 if (NULL == dc) 63 { 64 dc = GNUNET_new (struct KeyDeleteContext); 65 dc->connection = connection; 66 hc->ctx = dc; 67 } 68 69 enum GNUNET_DB_QueryStatus qs; 70 qs = db->delete_key_data (db->cls, 71 &id->id); 72 73 switch (qs) 74 { 75 case GNUNET_DB_STATUS_HARD_ERROR: 76 case GNUNET_DB_STATUS_SOFT_ERROR: 77 GNUNET_break (0); 78 return TALER_MHD_reply_with_error (connection, 79 MHD_HTTP_INTERNAL_SERVER_ERROR, 80 TALER_EC_GENERIC_DB_FETCH_FAILED, 81 "key_delete"); 82 case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: 83 case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: 84 break; 85 } 86 87 struct FH_RequestHandler h204 = { 88 "", NULL, "text/html", 89 "<html><title>204: no content</title></html>", 0, 90 &TMH_MHD_handler_static_response, MHD_HTTP_NO_CONTENT 91 }; 92 93 return TMH_MHD_handler_static_response (&h204, 94 connection); 95 }