From b38c3d61d829a5f5a798c4b185f39bc266d0167d Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Sun, 6 Sep 2020 13:19:10 +0200 Subject: [PATCH] fix: controller discovery now called by PUT --- include/endpoints/api_v1_controllers.h | 2 +- src/endpoints/api_v1_controllers_discover.c | 2 +- src/router.c | 2 +- tests/tavern_tests/1.0.controllers_basic.tavern.yaml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/endpoints/api_v1_controllers.h b/include/endpoints/api_v1_controllers.h index 6430079..5d96497 100644 --- a/include/endpoints/api_v1_controllers.h +++ b/include/endpoints/api_v1_controllers.h @@ -4,7 +4,7 @@ #include void -api_v1_controllers_discover_POST(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response); +api_v1_controllers_discover_PUT(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response); void api_v1_controllers_GET(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response); diff --git a/src/endpoints/api_v1_controllers_discover.c b/src/endpoints/api_v1_controllers_discover.c index c6d7648..189e5b6 100644 --- a/src/endpoints/api_v1_controllers_discover.c +++ b/src/endpoints/api_v1_controllers_discover.c @@ -105,7 +105,7 @@ send_udp_broadcast(const char *addr, uint16_t port, void *message, size_t length } void -api_v1_controllers_discover_POST(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response) +api_v1_controllers_discover_PUT(struct mg_connection *nc, struct http_message *hm, endpoint_args_t *args, endpoint_response_t *response) { (void)nc; (void)hm; diff --git a/src/router.c b/src/router.c index 13b8299..d052cec 100644 --- a/src/router.c +++ b/src/router.c @@ -72,7 +72,7 @@ router_init() router_register_endpoint("/api/v1/schedules/{str}", HTTP_METHOD_DELETE, api_v1_schedules_STR_DELETE); router_register_endpoint("/api/v1/schedules/tag/{str}", HTTP_METHOD_GET, api_v1_schedules_tag_STR_GET); - router_register_endpoint("/api/v1/controllers/discover/", HTTP_METHOD_POST, api_v1_controllers_discover_POST); + router_register_endpoint("/api/v1/controllers/discover/", HTTP_METHOD_PUT, api_v1_controllers_discover_PUT); router_register_endpoint("/api/v1/controllers/", HTTP_METHOD_GET, api_v1_controllers_GET); router_register_endpoint("/api/v1/controllers/{str}", HTTP_METHOD_GET, api_v1_controllers_STR_GET); router_register_endpoint("/api/v1/controllers/{str}", HTTP_METHOD_PUT, api_v1_controllers_STR_PUT); diff --git a/tests/tavern_tests/1.0.controllers_basic.tavern.yaml b/tests/tavern_tests/1.0.controllers_basic.tavern.yaml index a48ea17..3bce298 100644 --- a/tests/tavern_tests/1.0.controllers_basic.tavern.yaml +++ b/tests/tavern_tests/1.0.controllers_basic.tavern.yaml @@ -3,7 +3,7 @@ test_name: Test basic controller functions stages: - name: "[controllers_basic] discover controllers" request: - method: POST + method: PUT url: "http://localhost:5000/api/v1/controllers/discover/" response: status_code: 200 @@ -86,7 +86,7 @@ stages: - name: "[controllers_basic] discover controllers again" request: - method: POST + method: PUT url: "http://localhost:5000/api/v1/controllers/discover/" response: status_code: 200