Support configuring a function as 404 error handling

Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
This commit is contained in:
Jianhui Zhao committed 2017-12-30 11:30:33 +08:00
1 parent f4852fd9cc
commit b8ae313e0a
2 files changed
+7 -1

No files matched your search

+5
View File
@@ -122,6 +122,11 @@ static void uh_handle_request(struct uh_client *cl)
if (handle_file_request(cl, path))
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);
}
+2 -1
View File
@@ -30,10 +30,11 @@ struct uh_server {
struct avl_tree actions;
struct list_head clients;
void (*free)(struct uh_server *srv);
void (*set_docroot)(struct uh_server *srv, const char *docroot);
void (*set_index_file)(struct uh_server *srv, const char *index_file);
void (*error404_cb)(struct uh_client *cl);
#if (UHTTPD_SSL_SUPPORT)
int (*ssl_init)(struct uh_server *srv, const char *key, const char *crt);
#endif