From 5dfc382a9f8467cd15b6a0c3a6e022fca9fc4a30 Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Sat, 18 Jun 2016 18:16:22 +0000 Subject: - fix rest plugin --- src/gns/Makefile.am | 1 + src/gns/plugin_rest_gns.c | 6 +++--- src/identity/Makefile.am | 1 + src/identity/plugin_rest_identity.c | 22 +++++++++++----------- src/include/gnunet_rest_lib.h | 6 +++--- src/namestore/Makefile.am | 1 + src/namestore/plugin_rest_namestore.c | 26 +++++++++++++------------- 7 files changed, 33 insertions(+), 30 deletions(-) diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am index 04fe45224..33fd96d9d 100644 --- a/src/gns/Makefile.am +++ b/src/gns/Makefile.am @@ -237,6 +237,7 @@ libgnunet_plugin_rest_gns_la_LIBADD = \ $(top_builddir)/src/rest/libgnunetrest.la \ $(top_builddir)/src/identity/libgnunetidentity.la \ $(top_builddir)/src/jsonapi/libgnunetjsonapi.la \ + $(top_builddir)/src/jsonapi/libgnunetjsonapiutils.la \ $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \ $(LTLIBINTL) -ljansson -lmicrohttpd libgnunet_plugin_rest_gns_la_LDFLAGS = \ diff --git a/src/gns/plugin_rest_gns.c b/src/gns/plugin_rest_gns.c index ef49b82a9..3cddbc246 100644 --- a/src/gns/plugin_rest_gns.c +++ b/src/gns/plugin_rest_gns.c @@ -228,7 +228,7 @@ do_error (void *cls) struct LookupHandle *handle = cls; struct MHD_Response *resp; - resp = GNUNET_REST_create_json_response (NULL); + resp = GNUNET_REST_create_response (NULL); handle->proc (handle->proc_cls, resp, handle->response_code); cleanup_handle (handle); } @@ -324,7 +324,7 @@ process_lookup_result (void *cls, uint32_t rd_count, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result); json_decref (result_array); GNUNET_JSONAPI_document_delete (json_document); - resp = GNUNET_REST_create_json_response (result); + resp = GNUNET_REST_create_response (result); handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); GNUNET_free (result); cleanup_handle (handle); @@ -640,7 +640,7 @@ options_cont (struct GNUNET_REST_RequestHandle *con_handle, struct LookupHandle *handle = cls; //For GNS, independent of path return all options - resp = GNUNET_REST_create_json_response (NULL); + resp = GNUNET_REST_create_response (NULL); MHD_add_response_header (resp, "Access-Control-Allow-Methods", MHD_HTTP_METHOD_GET); diff --git a/src/identity/Makefile.am b/src/identity/Makefile.am index 9b28ac093..c6f6625f4 100644 --- a/src/identity/Makefile.am +++ b/src/identity/Makefile.am @@ -70,6 +70,7 @@ libgnunet_plugin_rest_identity_la_LIBADD = \ libgnunetidentity.la \ $(top_builddir)/src/rest/libgnunetrest.la \ $(top_builddir)/src/jsonapi/libgnunetjsonapi.la \ + $(top_builddir)/src/jsonapi/libgnunetjsonapiutils.la \ $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \ $(LTLIBINTL) -ljansson -lmicrohttpd libgnunet_plugin_rest_identity_la_LDFLAGS = \ diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c index f14c80f42..44e754e6c 100644 --- a/src/identity/plugin_rest_identity.c +++ b/src/identity/plugin_rest_identity.c @@ -279,7 +279,7 @@ do_error (void *cls) "{Error while processing request: %s}", &handle->emsg); - resp = GNUNET_REST_create_json_response (json_error); + resp = GNUNET_REST_create_response (json_error); handle->proc (handle->proc_cls, resp, handle->response_code); @@ -339,7 +339,7 @@ get_ego_for_subsys (void *cls, } GNUNET_JSONAPI_document_serialize (json_document, &result_str); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); - resp = GNUNET_REST_create_json_response (result_str); + resp = GNUNET_REST_create_response (result_str); GNUNET_JSONAPI_document_delete (json_document); handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); GNUNET_free (result_str); @@ -372,7 +372,7 @@ ego_info_response (struct GNUNET_REST_RequestHandle *con, if (GNUNET_NO == GNUNET_REST_namespace_match (handle->url, GNUNET_REST_API_NS_IDENTITY)) { - resp = GNUNET_REST_create_json_response (NULL); + resp = GNUNET_REST_create_response (NULL); handle->proc (handle->proc_cls, resp, MHD_HTTP_BAD_REQUEST); cleanup_handle (handle); return; @@ -444,7 +444,7 @@ ego_info_response (struct GNUNET_REST_RequestHandle *con, } GNUNET_JSONAPI_document_serialize (json_document, &result_str); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); - resp = GNUNET_REST_create_json_response (result_str); + resp = GNUNET_REST_create_response (result_str); GNUNET_JSONAPI_document_delete (json_document); handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); GNUNET_free (result_str); @@ -470,7 +470,7 @@ do_finished (void *cls, const char *emsg) GNUNET_SCHEDULER_add_now (&do_error, handle); return; } - resp = GNUNET_REST_create_json_response (NULL); + resp = GNUNET_REST_create_response (NULL); handle->proc (handle->proc_cls, resp, MHD_HTTP_NO_CONTENT); cleanup_handle (handle); } @@ -528,7 +528,7 @@ ego_create_cont (struct GNUNET_REST_RequestHandle *con, if (GNUNET_NO == GNUNET_JSONAPI_resource_check_type (json_res, GNUNET_REST_JSONAPI_IDENTITY_EGO)) { GNUNET_JSONAPI_document_delete (json_obj); - resp = GNUNET_REST_create_json_response (NULL); + resp = GNUNET_REST_create_response (NULL); handle->proc (handle->proc_cls, resp, MHD_HTTP_CONFLICT); cleanup_handle (handle); return; @@ -549,7 +549,7 @@ ego_create_cont (struct GNUNET_REST_RequestHandle *con, if (0 == strcasecmp (egoname, ego_entry->identifier)) { GNUNET_JSONAPI_document_delete (json_obj); - resp = GNUNET_REST_create_json_response (NULL); + resp = GNUNET_REST_create_response (NULL); handle->proc (handle->proc_cls, resp, MHD_HTTP_CONFLICT); cleanup_handle (handle); return; @@ -610,7 +610,7 @@ ego_edit_cont (struct GNUNET_REST_RequestHandle *con, if (GNUNET_NO == ego_exists) { - resp = GNUNET_REST_create_json_response (NULL); + resp = GNUNET_REST_create_response (NULL); handle->proc (handle->proc_cls, resp, MHD_HTTP_NOT_FOUND); cleanup_handle (handle); return; @@ -667,7 +667,7 @@ ego_edit_cont (struct GNUNET_REST_RequestHandle *con, { //Ego with same name not allowed GNUNET_JSONAPI_document_delete (json_obj); - resp = GNUNET_REST_create_json_response (NULL); + resp = GNUNET_REST_create_response (NULL); handle->proc (handle->proc_cls, resp, MHD_HTTP_CONFLICT); cleanup_handle (handle); return; @@ -731,7 +731,7 @@ ego_delete_cont (struct GNUNET_REST_RequestHandle *con_handle, } if (GNUNET_NO == ego_exists) { - resp = GNUNET_REST_create_json_response (NULL); + resp = GNUNET_REST_create_response (NULL); handle->proc (handle->proc_cls, resp, MHD_HTTP_NOT_FOUND); cleanup_handle (handle); return; @@ -760,7 +760,7 @@ options_cont (struct GNUNET_REST_RequestHandle *con_handle, struct RequestHandle *handle = cls; //For now, independent of path return all options - resp = GNUNET_REST_create_json_response (NULL); + resp = GNUNET_REST_create_response (NULL); MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods); diff --git a/src/include/gnunet_rest_lib.h b/src/include/gnunet_rest_lib.h index 0616a33d8..243c38403 100644 --- a/src/include/gnunet_rest_lib.h +++ b/src/include/gnunet_rest_lib.h @@ -95,13 +95,13 @@ int GNUNET_REST_namespace_match (const char *url, const char *namespace); /** - * Create JSON API MHD response + * Create REST MHD response * - * @param data JSON result + * @param data result * @retun MHD response */ struct MHD_Response* -GNUNET_REST_create_json_response (const char *data); +GNUNET_REST_create_response (const char *data); int diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am index 5fddebfa8..50b33a18a 100644 --- a/src/namestore/Makefile.am +++ b/src/namestore/Makefile.am @@ -195,6 +195,7 @@ libgnunet_plugin_rest_namestore_la_LIBADD = \ $(top_builddir)/src/rest/libgnunetrest.la \ $(top_builddir)/src/identity/libgnunetidentity.la \ $(top_builddir)/src/jsonapi/libgnunetjsonapi.la \ + $(top_builddir)/src/jsonapi/libgnunetjsonapiutils.la \ $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \ $(LTLIBINTL) -ljansson -lmicrohttpd libgnunet_plugin_rest_namestore_la_LDFLAGS = \ diff --git a/src/namestore/plugin_rest_namestore.c b/src/namestore/plugin_rest_namestore.c index 873a12b83..42959bed8 100644 --- a/src/namestore/plugin_rest_namestore.c +++ b/src/namestore/plugin_rest_namestore.c @@ -358,7 +358,7 @@ static void do_error (void *cls) { struct RequestHandle *handle = cls; - struct MHD_Response *resp = GNUNET_REST_create_json_response (NULL); + struct MHD_Response *resp = GNUNET_REST_create_response (NULL); handle->proc (handle->proc_cls, resp, handle->response_code); cleanup_handle (handle); @@ -419,9 +419,9 @@ namestore_list_response (void *cls, GNUNET_SCHEDULER_add_now (&do_error, handle); return; } - resp = GNUNET_REST_create_json_response (result); + resp = GNUNET_REST_create_response (result); handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); - GNUNET_free (result); + GNUNET_free_non_null (result); GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); return; } @@ -480,7 +480,7 @@ create_finished (void *cls, int32_t success, const char *emsg) GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); return; } - resp = GNUNET_REST_create_json_response (NULL); + resp = GNUNET_REST_create_response (NULL); handle->proc (handle->proc_cls, resp, MHD_HTTP_NO_CONTENT); GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); } @@ -517,7 +517,7 @@ create_new_record_cont (void *cls, if (0 != rd_count) { handle->proc (handle->proc_cls, - GNUNET_REST_create_json_response (NULL), + GNUNET_REST_create_response (NULL), MHD_HTTP_CONFLICT); GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); return; @@ -560,7 +560,7 @@ del_finished (void *cls, return; } handle->proc (handle->proc_cls, - GNUNET_REST_create_json_response (NULL), + GNUNET_REST_create_response (NULL), MHD_HTTP_NO_CONTENT); GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); } @@ -767,7 +767,7 @@ namestore_create_cont (struct GNUNET_REST_RequestHandle *con, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unsupported JSON data type\n"); GNUNET_JSONAPI_document_delete (json_obj); - resp = GNUNET_REST_create_json_response (NULL); + resp = GNUNET_REST_create_response (NULL); handle->proc (handle->proc_cls, resp, MHD_HTTP_CONFLICT); cleanup_handle (handle); return; @@ -831,7 +831,7 @@ namestore_zkey_response (void *cls, GNUNET_SCHEDULER_add_now (&do_error, handle); return; } - resp = GNUNET_REST_create_json_response (result); + resp = GNUNET_REST_create_response (result); handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); GNUNET_JSONAPI_document_delete (json_obj); GNUNET_free (result); @@ -916,7 +916,7 @@ options_cont (struct GNUNET_REST_RequestHandle *con_handle, struct RequestHandle *handle = cls; //For now, independent of path return all options - resp = GNUNET_REST_create_json_response (NULL); + resp = GNUNET_REST_create_response (NULL); MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods); @@ -999,7 +999,7 @@ identity_cb (void *cls, _("Ego `%s' not known to identity service\n"), handle->ego_name); } - resp = GNUNET_REST_create_json_response (NULL); + resp = GNUNET_REST_create_response (NULL); handle->proc (handle->proc_cls, resp, MHD_HTTP_NOT_FOUND); cleanup_handle (handle); return; @@ -1024,7 +1024,7 @@ default_ego_cb (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("No default ego configured in identity service\n")); - resp = GNUNET_REST_create_json_response (NULL); + resp = GNUNET_REST_create_response (NULL); handle->proc (handle->proc_cls, resp, MHD_HTTP_NOT_FOUND); cleanup_handle (handle); return; @@ -1064,7 +1064,7 @@ testservice_id_task (void *cls, int result) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Identity service is not running\n")); - resp = GNUNET_REST_create_json_response (NULL); + resp = GNUNET_REST_create_response (NULL); handle->proc (handle->proc_cls, resp, MHD_HTTP_NOT_FOUND); cleanup_handle (handle); return; @@ -1105,7 +1105,7 @@ testservice_id_task (void *cls, int result) if (NULL == handle->identity_handle) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Cannot connect to identity service\n")); - resp = GNUNET_REST_create_json_response (NULL); + resp = GNUNET_REST_create_response (NULL); handle->proc (handle->proc_cls, resp, MHD_HTTP_NOT_FOUND); cleanup_handle (handle); } -- cgit v1.2.3