diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2016-05-02 16:32:36 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2016-05-02 16:32:36 +0000 |
commit | bee208bcd6803829aa26c55a4c8e176a5f2c815f (patch) | |
tree | 6974bc9e94a1ec938b5376d2631233d2e75baf7d /src/gns/plugin_rest_gns.c | |
parent | fc9b25be2dbe5392501dbc0b6659c1aa50809bc2 (diff) | |
download | gnunet-bee208bcd6803829aa26c55a4c8e176a5f2c815f.tar.gz gnunet-bee208bcd6803829aa26c55a4c8e176a5f2c815f.zip |
- Refactor jsonapi into separate module
Diffstat (limited to 'src/gns/plugin_rest_gns.c')
-rw-r--r-- | src/gns/plugin_rest_gns.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/gns/plugin_rest_gns.c b/src/gns/plugin_rest_gns.c index 1315e6cda..91a091f2e 100644 --- a/src/gns/plugin_rest_gns.c +++ b/src/gns/plugin_rest_gns.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <gnunet_namestore_service.h> | 32 | #include <gnunet_namestore_service.h> |
33 | #include <gnunet_gns_service.h> | 33 | #include <gnunet_gns_service.h> |
34 | #include <gnunet_rest_lib.h> | 34 | #include <gnunet_rest_lib.h> |
35 | #include <gnunet_jsonapi_lib.h> | ||
35 | #include <jansson.h> | 36 | #include <jansson.h> |
36 | 37 | ||
37 | #define GNUNET_REST_API_NS_GNS "/gns" | 38 | #define GNUNET_REST_API_NS_GNS "/gns" |
@@ -284,16 +285,16 @@ process_lookup_result (void *cls, uint32_t rd_count, | |||
284 | { | 285 | { |
285 | struct LookupHandle *handle = cls; | 286 | struct LookupHandle *handle = cls; |
286 | struct MHD_Response *resp; | 287 | struct MHD_Response *resp; |
287 | struct JsonApiObject *json_object; | 288 | struct GNUNET_JSONAPI_Object *json_object; |
288 | struct JsonApiResource *json_resource; | 289 | struct GNUNET_JSONAPI_Resource *json_resource; |
289 | uint32_t i; | 290 | uint32_t i; |
290 | char *result; | 291 | char *result; |
291 | json_t *result_array; | 292 | json_t *result_array; |
292 | json_t *record_obj; | 293 | json_t *record_obj; |
293 | 294 | ||
294 | result_array = json_array(); | 295 | result_array = json_array(); |
295 | json_object = GNUNET_REST_jsonapi_object_new (); | 296 | json_object = GNUNET_JSONAPI_object_new (); |
296 | json_resource = GNUNET_REST_jsonapi_resource_new (GNUNET_REST_JSONAPI_GNS_TYPEINFO, handle->name); | 297 | json_resource = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_GNS_TYPEINFO, handle->name); |
297 | handle->lookup_request = NULL; | 298 | handle->lookup_request = NULL; |
298 | for (i=0; i<rd_count; i++) | 299 | for (i=0; i<rd_count; i++) |
299 | { | 300 | { |
@@ -304,14 +305,14 @@ process_lookup_result (void *cls, uint32_t rd_count, | |||
304 | json_array_append (result_array, record_obj); | 305 | json_array_append (result_array, record_obj); |
305 | json_decref (record_obj); | 306 | json_decref (record_obj); |
306 | } | 307 | } |
307 | GNUNET_REST_jsonapi_resource_add_attr (json_resource, | 308 | GNUNET_JSONAPI_resource_add_attr (json_resource, |
308 | GNUNET_REST_JSONAPI_GNS_RECORD, | 309 | GNUNET_REST_JSONAPI_GNS_RECORD, |
309 | result_array); | 310 | result_array); |
310 | GNUNET_REST_jsonapi_object_resource_add (json_object, json_resource); | 311 | GNUNET_JSONAPI_object_resource_add (json_object, json_resource); |
311 | GNUNET_REST_jsonapi_data_serialize (json_object, &result); | 312 | GNUNET_JSONAPI_data_serialize (json_object, &result); |
312 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result); | 313 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result); |
313 | json_decref (result_array); | 314 | json_decref (result_array); |
314 | GNUNET_REST_jsonapi_object_delete (json_object); | 315 | GNUNET_JSONAPI_object_delete (json_object); |
315 | resp = GNUNET_REST_create_json_response (result); | 316 | resp = GNUNET_REST_create_json_response (result); |
316 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 317 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
317 | GNUNET_free (result); | 318 | GNUNET_free (result); |