aboutsummaryrefslogtreecommitdiff
path: root/src/identity/plugin_rest_identity.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/identity/plugin_rest_identity.c')
-rw-r--r--src/identity/plugin_rest_identity.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c
index 8a2c24d1f..70ede69eb 100644
--- a/src/identity/plugin_rest_identity.c
+++ b/src/identity/plugin_rest_identity.c
@@ -55,6 +55,8 @@ struct Plugin
55 55
56const struct GNUNET_CONFIGURATION_Handle *cfg; 56const struct GNUNET_CONFIGURATION_Handle *cfg;
57 57
58static char* allow_methods;
59
58struct EgoEntry 60struct EgoEntry
59{ 61{
60 /** 62 /**
@@ -652,6 +654,23 @@ ego_delete_cont (struct RestConnectionDataHandle *con_handle,
652 654
653} 655}
654 656
657void
658options_cont (struct RestConnectionDataHandle *con_handle,
659 const char* url,
660 void *cls)
661{
662 struct MHD_Response *resp;
663 struct RequestHandle *handle = cls;
664
665 //For now, independent of path return all options
666 resp = GNUNET_REST_create_json_response (NULL);
667 MHD_add_response_header (resp,
668 "Access-Control-Allow-Methods",
669 allow_methods);
670 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
671 cleanup_handle (handle);
672 return;
673}
655 674
656/** 675/**
657 * Handle rest request 676 * Handle rest request
@@ -666,6 +685,7 @@ init_cont (struct RequestHandle *handle)
666 {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY, &ego_create_cont}, 685 {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY, &ego_create_cont},
667 {MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY, &ego_edit_cont}, 686 {MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY, &ego_edit_cont},
668 {MHD_HTTP_METHOD_DELETE, GNUNET_REST_API_NS_IDENTITY, &ego_delete_cont}, 687 {MHD_HTTP_METHOD_DELETE, GNUNET_REST_API_NS_IDENTITY, &ego_delete_cont},
688 {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_IDENTITY, &options_cont},
669 GNUNET_REST_HANDLER_END 689 GNUNET_REST_HANDLER_END
670 }; 690 };
671 691
@@ -799,7 +819,7 @@ libgnunet_plugin_rest_identity_init (void *cls)
799 api->cls = &plugin; 819 api->cls = &plugin;
800 api->name = GNUNET_REST_API_NS_IDENTITY; 820 api->name = GNUNET_REST_API_NS_IDENTITY;
801 api->process_request = &rest_identity_process_request; 821 api->process_request = &rest_identity_process_request;
802 GNUNET_asprintf (&api->allow_methods, 822 GNUNET_asprintf (&allow_methods,
803 "%s, %s, %s, %s, %s", 823 "%s, %s, %s, %s, %s",
804 MHD_HTTP_METHOD_GET, 824 MHD_HTTP_METHOD_GET,
805 MHD_HTTP_METHOD_POST, 825 MHD_HTTP_METHOD_POST,
@@ -826,7 +846,7 @@ libgnunet_plugin_rest_identity_done (void *cls)
826 struct Plugin *plugin = api->cls; 846 struct Plugin *plugin = api->cls;
827 847
828 plugin->cfg = NULL; 848 plugin->cfg = NULL;
829 GNUNET_free_non_null (api->allow_methods); 849 GNUNET_free_non_null (allow_methods);
830 GNUNET_free (api); 850 GNUNET_free (api);
831 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 851 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
832 "Identity REST plugin is finished\n"); 852 "Identity REST plugin is finished\n");