From 493305a0d4e9d7f9bdc35fabfd8027a487586e47 Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Wed, 4 May 2016 09:44:35 +0000 Subject: - rework rest/jsonapi API; bugfixes --- src/identity/plugin_rest_identity.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src/identity') diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c index 10836f103..4a2429a9c 100644 --- a/src/identity/plugin_rest_identity.c +++ b/src/identity/plugin_rest_identity.c @@ -146,7 +146,12 @@ struct RequestHandle /** * Handle to the rest connection */ - struct RestConnectionDataHandle *conndata_handle; + struct GNUNET_REST_RequestHandle *conndata_handle; + + /** + * response code + */ + int response_code; /** * The processing state @@ -276,7 +281,7 @@ do_error (void *cls) resp = GNUNET_REST_create_json_response (json_error); handle->proc (handle->proc_cls, resp, - MHD_HTTP_BAD_REQUEST); + handle->response_code); cleanup_handle (handle); GNUNET_free (json_error); } @@ -348,7 +353,7 @@ get_ego_for_subsys (void *cls, * @param cls the request handle */ static void -ego_info_response (struct RestConnectionDataHandle *con, +ego_info_response (struct GNUNET_REST_RequestHandle *con, const char *url, void *cls) { @@ -477,7 +482,7 @@ do_finished (void *cls, const char *emsg) * @param cls request handle */ static void -ego_create_cont (struct RestConnectionDataHandle *con, +ego_create_cont (struct GNUNET_REST_RequestHandle *con, const char *url, void *cls) { @@ -566,7 +571,7 @@ ego_create_cont (struct RestConnectionDataHandle *con, * @param cls the RequestHandle */ static void -ego_edit_cont (struct RestConnectionDataHandle *con, +ego_edit_cont (struct GNUNET_REST_RequestHandle *con, const char *url, void *cls) { @@ -696,7 +701,7 @@ ego_edit_cont (struct RestConnectionDataHandle *con, } void -ego_delete_cont (struct RestConnectionDataHandle *con_handle, +ego_delete_cont (struct GNUNET_REST_RequestHandle *con_handle, const char* url, void *cls) { @@ -746,7 +751,7 @@ ego_delete_cont (struct RestConnectionDataHandle *con_handle, * @param cls the RequestHandle */ static void -options_cont (struct RestConnectionDataHandle *con_handle, +options_cont (struct GNUNET_REST_RequestHandle *con_handle, const char* url, void *cls) { @@ -771,7 +776,8 @@ options_cont (struct RestConnectionDataHandle *con_handle, static void init_cont (struct RequestHandle *handle) { - static const struct GNUNET_REST_RestConnectionHandler handlers[] = { + struct GNUNET_REST_RequestHandlerError err; + static const struct GNUNET_REST_RequestHandler handlers[] = { {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY, &ego_info_response}, {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY, &ego_create_cont}, {MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY, &ego_edit_cont}, @@ -780,9 +786,12 @@ init_cont (struct RequestHandle *handle) GNUNET_REST_HANDLER_END }; - if (GNUNET_NO == GNUNET_REST_handle_request (handle->conndata_handle, handlers, handle)) + if (GNUNET_NO == GNUNET_JSONAPI_handle_request (handle->conndata_handle, + handlers, + &err, + handle)) { - handle->emsg = GNUNET_strdup ("Request unsupported"); + handle->response_code = err.error_code; GNUNET_SCHEDULER_add_now (&do_error, handle); } } @@ -860,7 +869,7 @@ list_ego (void *cls, * @return GNUNET_OK if request accepted */ static void -rest_identity_process_request(struct RestConnectionDataHandle *conndata_handle, +rest_identity_process_request(struct GNUNET_REST_RequestHandle *conndata_handle, GNUNET_REST_ResultProcessor proc, void *proc_cls) { -- cgit v1.2.3