From 89851e3f33e44ed775e40600369116d0f3c209b0 Mon Sep 17 00:00:00 2001 From: Jianhui Zhao Date: Mon, 1 Jan 2018 10:30:41 +0800 Subject: [PATCH] Optimize code Signed-off-by: Jianhui Zhao --- README.md | 2 +- README_ZH.md | 2 +- example/helloworld.c | 2 +- src/uhttpd.c | 1 + src/uhttpd.h | 1 + 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cd4d2ff..4b15632 100755 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ int main(int argc, char **argv) goto done; #endif - uh_add_action(srv, "/hello", hello_action); + srv->add_action(srv, "/hello", hello_action); uloop_run(); done: diff --git a/README_ZH.md b/README_ZH.md index be3d8bc..b7ca879 100755 --- a/README_ZH.md +++ b/README_ZH.md @@ -99,7 +99,7 @@ int main(int argc, char **argv) goto done; #endif - uh_add_action(srv, "/hello", hello_action); + srv->add_action(srv, "/hello", hello_action); uloop_run(); done: diff --git a/example/helloworld.c b/example/helloworld.c index 94600f3..cd55b9b 100755 --- a/example/helloworld.c +++ b/example/helloworld.c @@ -54,7 +54,7 @@ int main(int argc, char **argv) goto done; #endif - uh_add_action(srv, "/hello", hello_action); + srv->add_action(srv, "/hello", hello_action); uloop_run(); done: diff --git a/src/uhttpd.c b/src/uhttpd.c index c8fc563..d026f28 100755 --- a/src/uhttpd.c +++ b/src/uhttpd.c @@ -87,6 +87,7 @@ struct uh_server *uh_server_new(const char *host, const char *port) srv->free = uh_server_free; srv->set_docroot = uh_set_docroot; srv->set_index_file = uh_set_index_file; + srv->add_action = uh_add_action; #if (UHTTPD_SSL_SUPPORT) srv->ssl_init = uh_ssl_init; diff --git a/src/uhttpd.h b/src/uhttpd.h index 7b2e260..3c99288 100755 --- a/src/uhttpd.h +++ b/src/uhttpd.h @@ -34,6 +34,7 @@ struct uh_server { 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); + int (*add_action)(struct uh_server *srv, const char *path, action_cb_t cb); #if (UHTTPD_SSL_SUPPORT) int (*ssl_init)(struct uh_server *srv, const char *key, const char *crt);