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);
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;
}
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);
}
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;
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);
}
struct GNUNET_JSONAPI_Document *json_obj;
struct GNUNET_JSONAPI_Resource *json_res;
json_t *records_json;
+ json_t *data_js;
+ json_error_t err;
char term_data[handle->rest_handle->data_size+1];
-
+ struct GNUNET_JSON_Specification docspec[] = {
+ GNUNET_JSON_spec_jsonapi_document (&json_obj),
+ GNUNET_JSON_spec_end()
+ };
+
if (strlen (GNUNET_REST_API_NS_NAMESTORE) != strlen (handle->url))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
memcpy (term_data,
handle->rest_handle->data,
handle->rest_handle->data_size);
- GNUNET_assert (GNUNET_OK == GNUNET_JSONAPI_document_parse (term_data,
- &json_obj));
+ data_js = json_loads (term_data,
+ JSON_DECODE_ANY,
+ &err);
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_JSON_parse (data_js, docspec,
+ NULL, NULL));
+ json_decref (data_js);
if (NULL == json_obj)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
}
json_res = GNUNET_JSONAPI_document_get_resource (json_obj, 0);
if (GNUNET_NO == GNUNET_JSONAPI_resource_check_type (json_res,
- GNUNET_REST_JSONAPI_NAMESTORE_RECORD))
+ GNUNET_REST_JSONAPI_NAMESTORE_RECORD))
{
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;
}
handle->name = GNUNET_strdup (GNUNET_JSONAPI_resource_get_id (json_res));
records_json = GNUNET_JSONAPI_resource_read_attr (json_res,
- GNUNET_REST_JSONAPI_NAMESTORE_RECORD);
+ GNUNET_REST_JSONAPI_NAMESTORE_RECORD);
if (NULL == records_json)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
{
name_json = json_string (label);
json_res = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_NAMESTORE_REVINFO,
- handle->zkey_str);
+ handle->zkey_str);
GNUNET_JSONAPI_resource_add_attr (json_res,
- GNUNET_REST_JSONAPI_NAMESTORE_NAME,
- name_json);
+ GNUNET_REST_JSONAPI_NAMESTORE_NAME,
+ name_json);
GNUNET_JSONAPI_document_resource_add (json_obj, json_res);
json_decref (name_json);
}
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);
return;
}
handle->zkey_str = GNUNET_CONTAINER_multihashmap_get (handle->rest_handle->url_param_map,
- &key);
+ &key);
if (GNUNET_OK !=
GNUNET_CRYPTO_ecdsa_public_key_from_string (handle->zkey_str,
strlen (handle->zkey_str),
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);
_("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;
{
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;
{
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;
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);
}