add: forward schedule updates to relays

This commit is contained in:
Tobias Reisinger 2020-05-11 14:50:25 +02:00
parent 574a384d2f
commit 606f2483a5
5 changed files with 75 additions and 18 deletions
handlers

View file

@ -8,26 +8,33 @@ handler_connection(struct mg_connection *c, int ev, void *p)
{
if (ev == MG_EV_HTTP_REQUEST)
{
LOG_DEBUG("new http request\n");
struct http_message *hm = (struct http_message *) p;
LOG_DEBUG("new http request for %.*s\n", hm->uri.len, hm->uri.p);
endpoint_t *endpoint = router_find_endpoint(hm->uri.p, hm->uri.len, &hm->method);
if(endpoint && endpoint->func)
{
endpoint->func(c, endpoint->args, p);
for(int i = 0; i < endpoint->args_count; ++i)
if(endpoint->func)
{
if(endpoint->args[i].type == ENDPOINT_ARG_TYPE_STR)
endpoint->func(c, endpoint->args, p);
for(int i = 0; i < endpoint->args_count; ++i)
{
free((char*)endpoint->args[i].value.v_str);
if(endpoint->args[i].type == ENDPOINT_ARG_TYPE_STR)
{
free((char*)endpoint->args[i].value.v_str);
}
}
}
else
{
mg_send_head(c, 501, 0, "Content-Type: text/plain");
}
}
else
{
mg_send_head(c, 501, 0, "Content-Type: text/plain");
mg_send_head(c, 500, 0, "Content-Type: text/plain");
}
//mg_printf(c, "%.*s", (int)hm->message.len, hm->message.p);