diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2016-05-04 09:44:35 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2016-05-04 09:44:35 +0000 |
commit | 493305a0d4e9d7f9bdc35fabfd8027a487586e47 (patch) | |
tree | ec05c1bde5b5cfb7937de6f06dc3586f26f557f9 /src/include | |
parent | 8e9bb50b7543608c2c1a833a5b92f19941ed7a0a (diff) | |
download | gnunet-493305a0d4e9d7f9bdc35fabfd8027a487586e47.tar.gz gnunet-493305a0d4e9d7f9bdc35fabfd8027a487586e47.zip |
- rework rest/jsonapi API; bugfixes
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_jsonapi_lib.h | 37 | ||||
-rw-r--r-- | src/include/gnunet_rest_lib.h | 16 | ||||
-rw-r--r-- | src/include/gnunet_rest_plugin.h | 2 |
3 files changed, 49 insertions, 6 deletions
diff --git a/src/include/gnunet_jsonapi_lib.h b/src/include/gnunet_jsonapi_lib.h index 1e540f6b6..d4556c174 100644 --- a/src/include/gnunet_jsonapi_lib.h +++ b/src/include/gnunet_jsonapi_lib.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #define GNUNET_JSONAPI_LIB_H | 22 | #define GNUNET_JSONAPI_LIB_H |
23 | 23 | ||
24 | #include "gnunet_util_lib.h" | 24 | #include "gnunet_util_lib.h" |
25 | #include "gnunet_rest_lib.h" | ||
25 | #include "gnunet_json_lib.h" | 26 | #include "gnunet_json_lib.h" |
26 | 27 | ||
27 | 28 | ||
@@ -200,5 +201,41 @@ GNUNET_JSONAPI_data_serialize (const struct GNUNET_JSONAPI_Object *resp, | |||
200 | */ | 201 | */ |
201 | json_t* | 202 | json_t* |
202 | GNUNET_JSONAPI_resource_get_id (const struct GNUNET_JSONAPI_Resource *resource); | 203 | GNUNET_JSONAPI_resource_get_id (const struct GNUNET_JSONAPI_Resource *resource); |
204 | |||
205 | |||
203 | /* end of gnunet_jsonapi_lib.h */ | 206 | /* end of gnunet_jsonapi_lib.h */ |
207 | |||
208 | /** | ||
209 | * Check rest request for validity | ||
210 | * | ||
211 | * @param req handle to the request | ||
212 | * @return GNUNET_OK if valid | ||
213 | */ | ||
214 | int | ||
215 | GNUNET_JSONAPI_check_request_acceptable (struct GNUNET_REST_RequestHandle *req); | ||
216 | |||
217 | /** | ||
218 | * Check rest request for validity | ||
219 | * | ||
220 | * @param req handle to the request | ||
221 | * @return GNUNET_OK if valid | ||
222 | */ | ||
223 | int | ||
224 | GNUNET_JSONAPI_check_request_supported (struct GNUNET_REST_RequestHandle *req); | ||
225 | |||
226 | |||
227 | /** | ||
228 | * Handle jsonapi rest request. Checks request headers for jsonapi compliance | ||
229 | * | ||
230 | * @param req rest request handle | ||
231 | * @param handler rest request handlers | ||
232 | * @param cls closure | ||
233 | * @return GNUNET_OK if successful | ||
234 | */ | ||
235 | int | ||
236 | GNUNET_JSONAPI_handle_request (struct GNUNET_REST_RequestHandle *req, | ||
237 | const struct GNUNET_REST_RequestHandler *handlers, | ||
238 | struct GNUNET_REST_RequestHandlerError *err, | ||
239 | void *cls); | ||
240 | |||
204 | #endif | 241 | #endif |
diff --git a/src/include/gnunet_rest_lib.h b/src/include/gnunet_rest_lib.h index ea254cc9b..ecd825f3f 100644 --- a/src/include/gnunet_rest_lib.h +++ b/src/include/gnunet_rest_lib.h | |||
@@ -37,17 +37,22 @@ | |||
37 | 37 | ||
38 | #define GNUNET_REST_HANDLER_END {NULL, NULL, NULL} | 38 | #define GNUNET_REST_HANDLER_END {NULL, NULL, NULL} |
39 | 39 | ||
40 | struct RestConnectionDataHandle | 40 | struct GNUNET_REST_RequestHandle |
41 | { | 41 | { |
42 | struct GNUNET_CONTAINER_MultiHashMap *url_param_map; | 42 | struct GNUNET_CONTAINER_MultiHashMap *url_param_map; |
43 | const char *method; | 43 | const char *method; |
44 | const char *url; | 44 | const char *url; |
45 | const char *data; | 45 | const char *data; |
46 | size_t data_size; | 46 | size_t data_size; |
47 | }; | ||
47 | 48 | ||
49 | struct GNUNET_REST_RequestHandlerError | ||
50 | { | ||
51 | int error_code; | ||
52 | char* error_text; | ||
48 | }; | 53 | }; |
49 | 54 | ||
50 | struct GNUNET_REST_RestConnectionHandler | 55 | struct GNUNET_REST_RequestHandler |
51 | { | 56 | { |
52 | /** | 57 | /** |
53 | * Http method to handle | 58 | * Http method to handle |
@@ -62,7 +67,7 @@ struct GNUNET_REST_RestConnectionHandler | |||
62 | /** | 67 | /** |
63 | * callback handler | 68 | * callback handler |
64 | */ | 69 | */ |
65 | void (*proc) (struct RestConnectionDataHandle *handle, | 70 | void (*proc) (struct GNUNET_REST_RequestHandle *handle, |
66 | const char *url, | 71 | const char *url, |
67 | void *cls); | 72 | void *cls); |
68 | 73 | ||
@@ -101,8 +106,9 @@ GNUNET_REST_create_json_response (const char *data); | |||
101 | 106 | ||
102 | 107 | ||
103 | int | 108 | int |
104 | GNUNET_REST_handle_request (struct RestConnectionDataHandle *conn, | 109 | GNUNET_REST_handle_request (struct GNUNET_REST_RequestHandle *conn, |
105 | const struct GNUNET_REST_RestConnectionHandler *handlers, | 110 | const struct GNUNET_REST_RequestHandler *handlers, |
111 | struct GNUNET_REST_RequestHandlerError *err, | ||
106 | void *cls); | 112 | void *cls); |
107 | 113 | ||
108 | 114 | ||
diff --git a/src/include/gnunet_rest_plugin.h b/src/include/gnunet_rest_plugin.h index 6685cdec2..ecd5f66f1 100644 --- a/src/include/gnunet_rest_plugin.h +++ b/src/include/gnunet_rest_plugin.h | |||
@@ -71,7 +71,7 @@ struct GNUNET_REST_Plugin | |||
71 | * @param proc the callback for result | 71 | * @param proc the callback for result |
72 | * @param proc_cls closure for callback | 72 | * @param proc_cls closure for callback |
73 | */ | 73 | */ |
74 | void (*process_request) (struct RestConnectionDataHandle *handle, | 74 | void (*process_request) (struct GNUNET_REST_RequestHandle *handle, |
75 | GNUNET_REST_ResultProcessor proc, | 75 | GNUNET_REST_ResultProcessor proc, |
76 | void *proc_cls); | 76 | void *proc_cls); |
77 | 77 | ||