Files
mongoose/docs/c-api/http.h/mg_register_http_endpoint.md
T
Alexander Alashkin 9101cd0339 Use lld for ID
PUBLISHED_FROM=1246247fc29eb9a75b986ff7bb2d2350a52c03fc
2016-07-22 16:26:31 +00:00

1008 B

title, decl_name, symbol_kind, signature
title decl_name symbol_kind signature
mg_register_http_endpoint() mg_register_http_endpoint func void mg_register_http_endpoint(struct mg_connection *nc, const char *uri_path, mg_event_handler_t handler);

Register callback for specified http endpoint Note: if callback is registered it is called instead of callback provided in mg_bind

Example code snippet:

static void handle_hello1(struct mg_connection *nc, int ev, void *ev_data) {
  (void) ev; (void) ev_data;
  mg_printf(nc, "HTTP/1.0 200 OK\r\n\r\n[I am Hello1]");
 nc->flags |= MG_F_SEND_AND_CLOSE;
}

static void handle_hello1(struct mg_connection *nc, int ev, void *ev_data) {
 (void) ev; (void) ev_data;
  mg_printf(nc, "HTTP/1.0 200 OK\r\n\r\n[I am Hello2]");
 nc->flags |= MG_F_SEND_AND_CLOSE;
}

void init() {
  nc = mg_bind(&mgr, local_addr, cb1);
  mg_register_http_endpoint(nc, "/hello1", handle_hello1);
  mg_register_http_endpoint(nc, "/hello1/hello2", handle_hello2);
}