diff options
Diffstat (limited to 'src/mint/taler-mint-httpd_responses.h')
-rw-r--r-- | src/mint/taler-mint-httpd_responses.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/mint/taler-mint-httpd_responses.h b/src/mint/taler-mint-httpd_responses.h new file mode 100644 index 000000000..0e48341fd --- /dev/null +++ b/src/mint/taler-mint-httpd_responses.h | |||
@@ -0,0 +1,93 @@ | |||
1 | /* | ||
2 | This file is part of TALER | ||
3 | (C) 2014 GNUnet e.V. | ||
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 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 | TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> | ||
15 | */ | ||
16 | |||
17 | /** | ||
18 | * @file taler-mint-httpd_responses.h | ||
19 | * @brief API for generating the various replies of the mint; these | ||
20 | * functions are called TALER_MINT_reply_ and they generate | ||
21 | * and queue MHD response objects for a given connection. | ||
22 | * @author Florian Dold | ||
23 | * @author Benedikt Mueller | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #ifndef TALER_MINT_HTTPD_RESPONSES_H | ||
27 | #define TALER_MINT_HTTPD_RESPONSES_H | ||
28 | #include <gnunet/gnunet_util_lib.h> | ||
29 | #include <jansson.h> | ||
30 | #include <microhttpd.h> | ||
31 | #include <libpq-fe.h> | ||
32 | #include <pthread.h> | ||
33 | #include "taler-mint-httpd.h" | ||
34 | #include "taler-mint-httpd_mhd.h" | ||
35 | |||
36 | |||
37 | /** | ||
38 | * Send JSON object as response. Decreases the reference count of the | ||
39 | * JSON object. | ||
40 | * | ||
41 | * @param connection the MHD connection | ||
42 | * @param json the json object | ||
43 | * @param response_code the http response code | ||
44 | * @return MHD result code | ||
45 | */ | ||
46 | int | ||
47 | TALER_MINT_reply_json (struct MHD_Connection *connection, | ||
48 | json_t *json, | ||
49 | unsigned int response_code); | ||
50 | |||
51 | |||
52 | /** | ||
53 | * Function to call to handle the request by building a JSON | ||
54 | * reply from a format string and varargs. | ||
55 | * | ||
56 | * @param connection the MHD connection to handle | ||
57 | * @param response_code HTTP response code to use | ||
58 | * @param fmt format string for pack | ||
59 | * @param ... varargs | ||
60 | * @return MHD result code | ||
61 | */ | ||
62 | int | ||
63 | TALER_MINT_reply_json_pack (struct MHD_Connection *connection, | ||
64 | unsigned int response_code, | ||
65 | const char *fmt, | ||
66 | ...); | ||
67 | |||
68 | |||
69 | /** | ||
70 | * Send a response indicating an invalid argument. | ||
71 | * | ||
72 | * @param connection the MHD connection to use | ||
73 | * @param param_name the parameter that is invalid | ||
74 | * @return MHD result code | ||
75 | */ | ||
76 | int | ||
77 | TALER_MINT_reply_arg_invalid (struct MHD_Connection *connection, | ||
78 | const char *param_name); | ||
79 | |||
80 | |||
81 | /** | ||
82 | * Send a response indicating a missing argument. | ||
83 | * | ||
84 | * @param connection the MHD connection to use | ||
85 | * @param param_name the parameter that is missing | ||
86 | * @return a MHD result code | ||
87 | */ | ||
88 | int | ||
89 | TALER_MINT_reply_arg_missing (struct MHD_Connection *connection, | ||
90 | const char *param_name); | ||
91 | |||
92 | |||
93 | #endif | ||