init rewrite
This commit is contained in:
parent
9a44bc494e
commit
6d828fcffc
100 changed files with 50541 additions and 2707 deletions
handlers
28
handlers/connection.c
Normal file
28
handlers/connection.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include <mongoose.h>
|
||||
#include <logger.h>
|
||||
#include <router.h>
|
||||
#include <handlers.h>
|
||||
|
||||
void
|
||||
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;
|
||||
|
||||
endpoint_t *endpoint = router_find_endpoint(hm->uri.p, hm->uri.len, &hm->method);
|
||||
|
||||
if(endpoint && endpoint->func)
|
||||
{
|
||||
endpoint->func(c, endpoint->args, p);
|
||||
}
|
||||
else
|
||||
{
|
||||
mg_send_head(c, 501, 0, "Content-Type: text/plain");
|
||||
}
|
||||
|
||||
//mg_printf(c, "%.*s", (int)hm->message.len, hm->message.p);
|
||||
//mg_printf(c, "%.*s", (int)hm->body.len, hm->body.p);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue