add: response macros

add: preparation for more macro endpoints
This commit is contained in:
Tobias Reisinger 2020-09-05 13:29:46 +02:00
parent 9d2c48d645
commit 01ffb1d58d
26 changed files with 482 additions and 353 deletions

View file

@ -114,13 +114,7 @@ api_v1_controllers_discover_POST(struct mg_connection *nc, struct http_message *
if(discover_server_port == -1)
{
LOGGER_ERR("failed to get server port for discovery\n");
static const char content[] = "";
response->status_code = 500;
response->content_type = "text/plain";
response->content_length = STRLEN(content);;
response->content = content;
response->alloced_content = false;
M_RESPONSE_TEXT_STATIC(LOGGER_ERR, response, 500, "the server failed to prepare discovery");
return;
}
@ -130,13 +124,7 @@ api_v1_controllers_discover_POST(struct mg_connection *nc, struct http_message *
LOGGER_DEBUG("sending udp broadcast\n");
if(send_udp_broadcast("255.255.255.255", global_config.discovery_port, payload, sizeof(payload)) < 0)
{
LOGGER_ERR("failed to send UDP broadcast\n");
static const char content[] = "";
response->status_code = 500;
response->content_type = "text/plain";
response->content_length = STRLEN(content);;
response->content = content;
response->alloced_content = false;
M_RESPONSE_TEXT_STATIC(LOGGER_ERR, response, 500, "the server failed to send discovery broadcast");
return;
}