mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-26 22:41:03 +08:00
Add ability to enumerate endpoints
This commit is contained in:
parent
a350208f35
commit
e3a140c9a7
20
mongoose.c
20
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;
|
||||
|
||||
|
21
mongoose.h
21
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.
|
||||
*/
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user