aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gns/plugin_rest_gns.c2
-rw-r--r--src/identity/plugin_rest_identity.c24
-rw-r--r--src/include/gnunet_rest_plugin.h5
-rw-r--r--src/rest/gnunet-rest-server.c6
4 files changed, 22 insertions, 15 deletions
diff --git a/src/gns/plugin_rest_gns.c b/src/gns/plugin_rest_gns.c
index 1a5ee9eea..d7fc31d4c 100644
--- a/src/gns/plugin_rest_gns.c
+++ b/src/gns/plugin_rest_gns.c
@@ -648,7 +648,6 @@ libgnunet_plugin_rest_gns_init (void *cls)
648 api->cls = &plugin; 648 api->cls = &plugin;
649 api->name = API_NAMESPACE; 649 api->name = API_NAMESPACE;
650 api->process_request = &rest_gns_process_request; 650 api->process_request = &rest_gns_process_request;
651 GNUNET_asprintf (&api->allow_methods, "%s", MHD_HTTP_METHOD_GET);
652 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 651 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
653 _("GNS REST API initialized\n")); 652 _("GNS REST API initialized\n"));
654 return api; 653 return api;
@@ -668,7 +667,6 @@ libgnunet_plugin_rest_gns_done (void *cls)
668 struct Plugin *plugin = api->cls; 667 struct Plugin *plugin = api->cls;
669 668
670 plugin->cfg = NULL; 669 plugin->cfg = NULL;
671 GNUNET_free_non_null (api->allow_methods);
672 GNUNET_free (api); 670 GNUNET_free (api);
673 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 671 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
674 "GNS REST plugin is finished\n"); 672 "GNS REST plugin is finished\n");
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");
diff --git a/src/include/gnunet_rest_plugin.h b/src/include/gnunet_rest_plugin.h
index abc0aea4c..e1eabd813 100644
--- a/src/include/gnunet_rest_plugin.h
+++ b/src/include/gnunet_rest_plugin.h
@@ -59,11 +59,6 @@ struct GNUNET_REST_Plugin
59 char *name; 59 char *name;
60 60
61 /** 61 /**
62 * Supported HTTP Methods
63 */
64 char *allow_methods;
65
66 /**
67 * Function to process a REST call 62 * Function to process a REST call
68 * 63 *
69 * @param method the HTTP method called 64 * @param method the HTTP method called
diff --git a/src/rest/gnunet-rest-server.c b/src/rest/gnunet-rest-server.c
index 3ce177e9c..9aa6fa40e 100644
--- a/src/rest/gnunet-rest-server.c
+++ b/src/rest/gnunet-rest-server.c
@@ -350,12 +350,6 @@ create_response (void *cls,
350 "Access-Control-Allow-Headers", 350 "Access-Control-Allow-Headers",
351 allow_headers); 351 allow_headers);
352 } 352 }
353 if (NULL != con_handle->plugin)
354 {
355 MHD_add_response_header (con_handle->response,
356 "Access-Control-Allow-Methods",
357 con_handle->plugin->allow_methods);
358 }
359 } 353 }
360 int ret = MHD_queue_response (con, 354 int ret = MHD_queue_response (con,
361 con_handle->status, 355 con_handle->status,