Support configuring a function as 404 error handling
Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>main
parent
f4852fd9cc
commit
b8ae313e0a
|
@ -122,6 +122,11 @@ static void uh_handle_request(struct uh_client *cl)
|
||||||
if (handle_file_request(cl, path))
|
if (handle_file_request(cl, path))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (cl->srv->error404_cb) {
|
||||||
|
cl->srv->error404_cb(cl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
cl->send_error(cl, 404, "Not Found", "The requested PATH %s was not found on this server.", path);
|
cl->send_error(cl, 404, "Not Found", "The requested PATH %s was not found on this server.", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,10 +30,11 @@ struct uh_server {
|
||||||
struct avl_tree actions;
|
struct avl_tree actions;
|
||||||
struct list_head clients;
|
struct list_head clients;
|
||||||
|
|
||||||
|
|
||||||
void (*free)(struct uh_server *srv);
|
void (*free)(struct uh_server *srv);
|
||||||
void (*set_docroot)(struct uh_server *srv, const char *docroot);
|
void (*set_docroot)(struct uh_server *srv, const char *docroot);
|
||||||
void (*set_index_file)(struct uh_server *srv, const char *index_file);
|
void (*set_index_file)(struct uh_server *srv, const char *index_file);
|
||||||
|
void (*error404_cb)(struct uh_client *cl);
|
||||||
|
|
||||||
#if (UHTTPD_SSL_SUPPORT)
|
#if (UHTTPD_SSL_SUPPORT)
|
||||||
int (*ssl_init)(struct uh_server *srv, const char *key, const char *crt);
|
int (*ssl_init)(struct uh_server *srv, const char *key, const char *crt);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue