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/identity/plugin_rest_identity.c | |
parent | 8e9bb50b7543608c2c1a833a5b92f19941ed7a0a (diff) | |
download | gnunet-493305a0d4e9d7f9bdc35fabfd8027a487586e47.tar.gz gnunet-493305a0d4e9d7f9bdc35fabfd8027a487586e47.zip |
- rework rest/jsonapi API; bugfixes
Diffstat (limited to 'src/identity/plugin_rest_identity.c')
-rw-r--r-- | src/identity/plugin_rest_identity.c | 31 |
1 files changed, 20 insertions, 11 deletions
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 | |||
146 | /** | 146 | /** |
147 | * Handle to the rest connection | 147 | * Handle to the rest connection |
148 | */ | 148 | */ |
149 | struct RestConnectionDataHandle *conndata_handle; | 149 | struct GNUNET_REST_RequestHandle *conndata_handle; |
150 | |||
151 | /** | ||
152 | * response code | ||
153 | */ | ||
154 | int response_code; | ||
150 | 155 | ||
151 | /** | 156 | /** |
152 | * The processing state | 157 | * The processing state |
@@ -276,7 +281,7 @@ do_error (void *cls) | |||
276 | resp = GNUNET_REST_create_json_response (json_error); | 281 | resp = GNUNET_REST_create_json_response (json_error); |
277 | handle->proc (handle->proc_cls, | 282 | handle->proc (handle->proc_cls, |
278 | resp, | 283 | resp, |
279 | MHD_HTTP_BAD_REQUEST); | 284 | handle->response_code); |
280 | cleanup_handle (handle); | 285 | cleanup_handle (handle); |
281 | GNUNET_free (json_error); | 286 | GNUNET_free (json_error); |
282 | } | 287 | } |
@@ -348,7 +353,7 @@ get_ego_for_subsys (void *cls, | |||
348 | * @param cls the request handle | 353 | * @param cls the request handle |
349 | */ | 354 | */ |
350 | static void | 355 | static void |
351 | ego_info_response (struct RestConnectionDataHandle *con, | 356 | ego_info_response (struct GNUNET_REST_RequestHandle *con, |
352 | const char *url, | 357 | const char *url, |
353 | void *cls) | 358 | void *cls) |
354 | { | 359 | { |
@@ -477,7 +482,7 @@ do_finished (void *cls, const char *emsg) | |||
477 | * @param cls request handle | 482 | * @param cls request handle |
478 | */ | 483 | */ |
479 | static void | 484 | static void |
480 | ego_create_cont (struct RestConnectionDataHandle *con, | 485 | ego_create_cont (struct GNUNET_REST_RequestHandle *con, |
481 | const char *url, | 486 | const char *url, |
482 | void *cls) | 487 | void *cls) |
483 | { | 488 | { |
@@ -566,7 +571,7 @@ ego_create_cont (struct RestConnectionDataHandle *con, | |||
566 | * @param cls the RequestHandle | 571 | * @param cls the RequestHandle |
567 | */ | 572 | */ |
568 | static void | 573 | static void |
569 | ego_edit_cont (struct RestConnectionDataHandle *con, | 574 | ego_edit_cont (struct GNUNET_REST_RequestHandle *con, |
570 | const char *url, | 575 | const char *url, |
571 | void *cls) | 576 | void *cls) |
572 | { | 577 | { |
@@ -696,7 +701,7 @@ ego_edit_cont (struct RestConnectionDataHandle *con, | |||
696 | } | 701 | } |
697 | 702 | ||
698 | void | 703 | void |
699 | ego_delete_cont (struct RestConnectionDataHandle *con_handle, | 704 | ego_delete_cont (struct GNUNET_REST_RequestHandle *con_handle, |
700 | const char* url, | 705 | const char* url, |
701 | void *cls) | 706 | void *cls) |
702 | { | 707 | { |
@@ -746,7 +751,7 @@ ego_delete_cont (struct RestConnectionDataHandle *con_handle, | |||
746 | * @param cls the RequestHandle | 751 | * @param cls the RequestHandle |
747 | */ | 752 | */ |
748 | static void | 753 | static void |
749 | options_cont (struct RestConnectionDataHandle *con_handle, | 754 | options_cont (struct GNUNET_REST_RequestHandle *con_handle, |
750 | const char* url, | 755 | const char* url, |
751 | void *cls) | 756 | void *cls) |
752 | { | 757 | { |
@@ -771,7 +776,8 @@ options_cont (struct RestConnectionDataHandle *con_handle, | |||
771 | static void | 776 | static void |
772 | init_cont (struct RequestHandle *handle) | 777 | init_cont (struct RequestHandle *handle) |
773 | { | 778 | { |
774 | static const struct GNUNET_REST_RestConnectionHandler handlers[] = { | 779 | struct GNUNET_REST_RequestHandlerError err; |
780 | static const struct GNUNET_REST_RequestHandler handlers[] = { | ||
775 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY, &ego_info_response}, | 781 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY, &ego_info_response}, |
776 | {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY, &ego_create_cont}, | 782 | {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY, &ego_create_cont}, |
777 | {MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY, &ego_edit_cont}, | 783 | {MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY, &ego_edit_cont}, |
@@ -780,9 +786,12 @@ init_cont (struct RequestHandle *handle) | |||
780 | GNUNET_REST_HANDLER_END | 786 | GNUNET_REST_HANDLER_END |
781 | }; | 787 | }; |
782 | 788 | ||
783 | if (GNUNET_NO == GNUNET_REST_handle_request (handle->conndata_handle, handlers, handle)) | 789 | if (GNUNET_NO == GNUNET_JSONAPI_handle_request (handle->conndata_handle, |
790 | handlers, | ||
791 | &err, | ||
792 | handle)) | ||
784 | { | 793 | { |
785 | handle->emsg = GNUNET_strdup ("Request unsupported"); | 794 | handle->response_code = err.error_code; |
786 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 795 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
787 | } | 796 | } |
788 | } | 797 | } |
@@ -860,7 +869,7 @@ list_ego (void *cls, | |||
860 | * @return GNUNET_OK if request accepted | 869 | * @return GNUNET_OK if request accepted |
861 | */ | 870 | */ |
862 | static void | 871 | static void |
863 | rest_identity_process_request(struct RestConnectionDataHandle *conndata_handle, | 872 | rest_identity_process_request(struct GNUNET_REST_RequestHandle *conndata_handle, |
864 | GNUNET_REST_ResultProcessor proc, | 873 | GNUNET_REST_ResultProcessor proc, |
865 | void *proc_cls) | 874 | void *proc_cls) |
866 | { | 875 | { |