diff --git a/mongoose.c b/mongoose.c index 8808fb82..eb14853c 100644 --- a/mongoose.c +++ b/mongoose.c @@ -5752,19 +5752,6 @@ struct mg_http_proto_data_chuncked { int64_t body_len; /* How many bytes of chunked body was reassembled. */ }; -struct mg_http_endpoint { - struct mg_http_endpoint *next; - struct mg_str uri_pattern; /* owned */ - char *auth_domain; /* owned */ - char *auth_file; /* owned */ - enum mg_auth_algo auth_algo; - - mg_event_handler_t handler; -#if MG_ENABLE_CALLBACK_USERDATA - void *user_data; -#endif -}; - enum mg_http_multipart_stream_state { MPS_BEGIN, MPS_WAITING_FOR_BOUNDARY, @@ -5869,6 +5856,13 @@ static void mg_http_free_proto_data_file(struct mg_http_proto_data_file *d) { } #endif +struct mg_http_endpoint *mg_get_http_endpoints(struct mg_connection *nc) { + if (nc == NULL) return NULL; + struct mg_http_proto_data *pd = (struct mg_http_proto_data *) nc->proto_data; + if (pd == NULL) return NULL; + return pd->endpoints; +} + static void mg_http_free_proto_data_endpoints(struct mg_http_endpoint **ep) { struct mg_http_endpoint *current = *ep; diff --git a/mongoose.h b/mongoose.h index 5559b0a6..144f8097 100644 --- a/mongoose.h +++ b/mongoose.h @@ -5184,6 +5184,27 @@ void mg_register_http_endpoint_opt(struct mg_connection *nc, mg_event_handler_t handler, struct mg_http_endpoint_opts opts); +/* + * HTTP endpoint descriptor. + */ +struct mg_http_endpoint { + struct mg_http_endpoint *next; + struct mg_str uri_pattern; /* owned */ + char *auth_domain; /* owned */ + char *auth_file; /* owned */ + enum mg_auth_algo auth_algo; + + mg_event_handler_t handler; +#if MG_ENABLE_CALLBACK_USERDATA + void *user_data; +#endif +}; + +/* + * Returns first registered endpoint. + */ +struct mg_http_endpoint *mg_get_http_endpoints(struct mg_connection *nc); + /* * Sends 401 Unauthorized response. */ diff --git a/src/mg_http.c b/src/mg_http.c index 87bdebf2..d594bd41 100644 --- a/src/mg_http.c +++ b/src/mg_http.c @@ -107,19 +107,6 @@ struct mg_http_proto_data_chuncked { int64_t body_len; /* How many bytes of chunked body was reassembled. */ }; -struct mg_http_endpoint { - struct mg_http_endpoint *next; - struct mg_str uri_pattern; /* owned */ - char *auth_domain; /* owned */ - char *auth_file; /* owned */ - enum mg_auth_algo auth_algo; - - mg_event_handler_t handler; -#if MG_ENABLE_CALLBACK_USERDATA - void *user_data; -#endif -}; - enum mg_http_multipart_stream_state { MPS_BEGIN, MPS_WAITING_FOR_BOUNDARY, @@ -224,6 +211,13 @@ static void mg_http_free_proto_data_file(struct mg_http_proto_data_file *d) { } #endif +struct mg_http_endpoint *mg_get_http_endpoints(struct mg_connection *nc) { + if (nc == NULL) return NULL; + struct mg_http_proto_data *pd = (struct mg_http_proto_data *) nc->proto_data; + if (pd == NULL) return NULL; + return pd->endpoints; +} + static void mg_http_free_proto_data_endpoints(struct mg_http_endpoint **ep) { struct mg_http_endpoint *current = *ep; diff --git a/src/mg_http_server.h b/src/mg_http_server.h index 9bc70011..e205a9ae 100644 --- a/src/mg_http_server.h +++ b/src/mg_http_server.h @@ -447,6 +447,27 @@ void mg_register_http_endpoint_opt(struct mg_connection *nc, mg_event_handler_t handler, struct mg_http_endpoint_opts opts); +/* + * HTTP endpoint descriptor. + */ +struct mg_http_endpoint { + struct mg_http_endpoint *next; + struct mg_str uri_pattern; /* owned */ + char *auth_domain; /* owned */ + char *auth_file; /* owned */ + enum mg_auth_algo auth_algo; + + mg_event_handler_t handler; +#if MG_ENABLE_CALLBACK_USERDATA + void *user_data; +#endif +}; + +/* + * Returns first registered endpoint. + */ +struct mg_http_endpoint *mg_get_http_endpoints(struct mg_connection *nc); + /* * Sends 401 Unauthorized response. */