aboutsummaryrefslogtreecommitdiff
path: root/src/gns/plugin_rest_gns.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gns/plugin_rest_gns.c')
-rw-r--r--src/gns/plugin_rest_gns.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/src/gns/plugin_rest_gns.c b/src/gns/plugin_rest_gns.c
index aae14153d..4be583f73 100644
--- a/src/gns/plugin_rest_gns.c
+++ b/src/gns/plugin_rest_gns.c
@@ -24,6 +24,7 @@
24#include "platform.h" 24#include "platform.h"
25#include "gnunet_rest_plugin.h" 25#include "gnunet_rest_plugin.h"
26#include "gnunet_rest_lib.h" 26#include "gnunet_rest_lib.h"
27#include "gnunet_json_lib.h"
27#include "gnunet_gnsrecord_lib.h" 28#include "gnunet_gnsrecord_lib.h"
28#include "gnunet_gns_service.h" 29#include "gnunet_gns_service.h"
29#include "microhttpd.h" 30#include "microhttpd.h"
@@ -31,9 +32,9 @@
31 32
32#define GNUNET_REST_API_NS_GNS "/gns" 33#define GNUNET_REST_API_NS_GNS "/gns"
33 34
34#define GNUNET_REST_PARAMETER_GNS_NAME "name" 35#define GNUNET_REST_GNS_PARAM_NAME "name"
35 36
36#define GNUNET_REST_PARAMETER_GNS_RECORD_TYPE "record_type" 37#define GNUNET_REST_GNS_PARAM_RECORD_TYPE "record_type"
37#define GNUNET_REST_GNS_ERROR_UNKNOWN "Unknown Error" 38#define GNUNET_REST_GNS_ERROR_UNKNOWN "Unknown Error"
38 39
39/** 40/**
@@ -203,7 +204,6 @@ handle_gns_response (void *cls,
203 uint32_t rd_count, 204 uint32_t rd_count,
204 const struct GNUNET_GNSRECORD_Data *rd) 205 const struct GNUNET_GNSRECORD_Data *rd)
205{ 206{
206 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "TEST4\n");
207 struct RequestHandle *handle = cls; 207 struct RequestHandle *handle = cls;
208 struct MHD_Response *resp; 208 struct MHD_Response *resp;
209 json_t *result_array; 209 json_t *result_array;
@@ -229,10 +229,7 @@ handle_gns_response (void *cls,
229 continue; 229 continue;
230 } 230 }
231 231
232 record_value = GNUNET_GNSRECORD_value_to_string (rd->record_type, 232 record_obj = GNUNET_JSON_from_gns_record(NULL,&rd[i]);
233 rd->data,
234 rd->data_size);
235 record_obj = json_string(record_value);
236 json_array_append (result_array, record_obj); 233 json_array_append (result_array, record_obj);
237 json_decref (record_obj); 234 json_decref (record_obj);
238 } 235 }
@@ -264,8 +261,8 @@ get_gns_cont (struct GNUNET_REST_RequestHandle *con_handle,
264 char *record_type; 261 char *record_type;
265 char *name; 262 char *name;
266 263
267 GNUNET_CRYPTO_hash (GNUNET_REST_PARAMETER_GNS_NAME, 264 GNUNET_CRYPTO_hash (GNUNET_REST_GNS_PARAM_NAME,
268 strlen (GNUNET_REST_PARAMETER_GNS_NAME), 265 strlen (GNUNET_REST_GNS_PARAM_NAME),
269 &key); 266 &key);
270 if ( GNUNET_NO 267 if ( GNUNET_NO
271 == GNUNET_CONTAINER_multihashmap_contains (con_handle->url_param_map, 268 == GNUNET_CONTAINER_multihashmap_contains (con_handle->url_param_map,
@@ -284,23 +281,19 @@ get_gns_cont (struct GNUNET_REST_RequestHandle *con_handle,
284 } 281 }
285 handle->name = GNUNET_strdup(name); 282 handle->name = GNUNET_strdup(name);
286 283
287 GNUNET_CRYPTO_hash (GNUNET_REST_PARAMETER_GNS_RECORD_TYPE, 284 handle->record_type = UINT32_MAX;
288 strlen (GNUNET_REST_PARAMETER_GNS_RECORD_TYPE), 285 GNUNET_CRYPTO_hash (GNUNET_REST_GNS_PARAM_RECORD_TYPE,
286 strlen (GNUNET_REST_GNS_PARAM_RECORD_TYPE),
289 &key); 287 &key);
290 if ( GNUNET_NO 288 if ( GNUNET_YES
291 == GNUNET_CONTAINER_multihashmap_contains (con_handle->url_param_map, 289 == GNUNET_CONTAINER_multihashmap_contains (con_handle->url_param_map,
292 &key)) 290 &key))
293 { 291 {
294 handle->emsg = GNUNET_strdup("Parameter record_type is missing"); 292 record_type = GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map, &key);
295 GNUNET_SCHEDULER_add_now (&do_error, handle); 293 handle->record_type = GNUNET_GNSRECORD_typename_to_number(record_type);
296 return;
297 } 294 }
298 295
299 296
300 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "TEST1\n");
301
302 record_type = GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map, &key);
303 handle->record_type = GNUNET_GNSRECORD_typename_to_number(record_type);
304 if(UINT32_MAX == handle->record_type) 297 if(UINT32_MAX == handle->record_type)
305 { 298 {
306 handle->record_type = GNUNET_GNSRECORD_TYPE_ANY; 299 handle->record_type = GNUNET_GNSRECORD_TYPE_ANY;
@@ -313,7 +306,6 @@ get_gns_cont (struct GNUNET_REST_RequestHandle *con_handle,
313 GNUNET_SCHEDULER_add_now (&do_error, handle); 306 GNUNET_SCHEDULER_add_now (&do_error, handle);
314 return; 307 return;
315 } 308 }
316 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "TEST2\n");
317 309
318 handle->gns_lookup = GNUNET_GNS_lookup_with_tld (handle->gns, 310 handle->gns_lookup = GNUNET_GNS_lookup_with_tld (handle->gns,
319 handle->name, 311 handle->name,