* Rest connection
*/
struct GNUNET_REST_RequestHandle *rest_handle;
-
+
/**
* Desired timeout for the lookup (default is no timeout).
*/
GNUNET_free (handle->name);
if (NULL != handle->emsg)
GNUNET_free (handle->emsg);
-
+
GNUNET_free (handle);
}
{
struct RequestHandle *handle = cls;
struct MHD_Response *resp;
- json_t *result_array;
- json_t *record_obj;
+ json_t *result_obj;
char *result;
handle->gns_lookup = NULL;
return;
}
- result_array = json_array();
- for (uint32_t i=0;i<rd_count;i++)
- {
- if ((rd[i].record_type != handle->record_type) &&
- (GNUNET_GNSRECORD_TYPE_ANY != handle->record_type) )
- {
- continue;
- }
-
- record_obj = GNUNET_JSON_from_gns_record(NULL,&rd[i]);
- json_array_append (result_array, record_obj);
- json_decref (record_obj);
- }
+ result_obj = GNUNET_JSON_from_gnsrecord (handle->name, rd, rd_count);
- result = json_dumps(result_array, 0);
+ result = json_dumps(result_obj, 0);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result);
resp = GNUNET_REST_create_response (result);
handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
GNUNET_free (result);
- json_decref (result_array);
+ json_decref (result_obj);
GNUNET_SCHEDULER_add_now(&cleanup_handle, handle);
}