Optimize code

Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
main
Jianhui Zhao 2018-01-01 10:30:41 +08:00
parent 4fc1826889
commit 89851e3f33
5 changed files with 5 additions and 3 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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;

View File

@ -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);