aboutsummaryrefslogtreecommitdiff
path: root/src/jsonapi/jsonapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/jsonapi/jsonapi.c')
-rw-r--r--src/jsonapi/jsonapi.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/jsonapi/jsonapi.c b/src/jsonapi/jsonapi.c
index 6bd03e0ec..b648590e5 100644
--- a/src/jsonapi/jsonapi.c
+++ b/src/jsonapi/jsonapi.c
@@ -20,6 +20,7 @@
20 */ 20 */
21#include "platform.h" 21#include "platform.h"
22#include "gnunet_json_lib.h" 22#include "gnunet_json_lib.h"
23#include "gnunet_rest_lib.h"
23 24
24#define GNUNET_JSONAPI_KEY_DATA "data" 25#define GNUNET_JSONAPI_KEY_DATA "data"
25 26
@@ -476,3 +477,56 @@ GNUNET_JSON_spec_jsonapi (struct GNUNET_JSONAPI_Object **jsonapi_object)
476 *jsonapi_object = NULL; 477 *jsonapi_object = NULL;
477 return ret; 478 return ret;
478} 479}
480
481/**
482 * Check rest request for validity
483 *
484 * @param req handle to the request
485 * @return GNUNET_OK if valid
486 */
487int
488GNUNET_JSONAPI_check_request_acceptable (struct GNUNET_REST_RequestHandle *req)
489{
490 //TODO
491 return GNUNET_OK;
492}
493
494/**
495 * Check rest request for validity
496 *
497 * @param req handle to the request
498 * @return GNUNET_OK if valid
499 */
500int
501GNUNET_JSONAPI_check_request_supported (struct GNUNET_REST_RequestHandle *req)
502{
503 //TODO
504 return GNUNET_OK;
505}
506
507/**
508 * Handle jsonapi rest request. Checks request headers for jsonapi compliance
509 *
510 * @param req rest request handle
511 * @param handler rest request handlers
512 * @param cls closure
513 * @return GNUNET_OK if successful
514 */
515int
516GNUNET_JSONAPI_handle_request (struct GNUNET_REST_RequestHandle *handle,
517 const struct GNUNET_REST_RequestHandler *handlers,
518 struct GNUNET_REST_RequestHandlerError *err,
519 void *cls)
520{
521 if (GNUNET_OK != GNUNET_JSONAPI_check_request_acceptable (handle))
522 {
523 err->error_code = MHD_HTTP_NOT_ACCEPTABLE;
524 return GNUNET_SYSERR;
525 }
526 if (GNUNET_OK != GNUNET_JSONAPI_check_request_supported (handle))
527 {
528 err->error_code = MHD_HTTP_UNSUPPORTED_MEDIA_TYPE;
529 return GNUNET_SYSERR;
530 }
531 return GNUNET_REST_handle_request (handle, handlers, err, cls);
532}