Lua API: Add path field

Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
main
Jianhui Zhao 2018-07-18 14:13:12 +08:00
parent 365e84fec3
commit 87c00d2291
2 changed files with 4 additions and 0 deletions

1
example/lua/helloworld.lua 100644 → 100755
View File

@ -41,6 +41,7 @@ srv:add_action("/lua", function(cl, opt)
uh.chunk_send(cl, string.format("<h1>REMOTE_ADDR: %s</h1>", opt.peer_addr))
uh.chunk_send(cl, string.format("<h1>METHOD: %s</h1>", opt.method))
uh.chunk_send(cl, string.format("<h1>HTTP Version: %s</h1>", opt.version))
uh.chunk_send(cl, string.format("<h1>PATH: %s</h1>", opt.path))
uh.chunk_send(cl, string.format("<h1>URL: %s</h1>", opt.url))
uh.chunk_send(cl, string.format("<h1>QUERY: %s</h1>", opt.query))
uh.chunk_send(cl, string.format("<h1>Body: %s</h1>", opt.body and opt.body or ""))

View File

@ -101,6 +101,9 @@ static void lua_uh_action(struct uh_client *cl)
lua_pushstring(L, cl->get_version(cl));
lua_setfield(L, -2, "version");
lua_pushstring(L, cl->get_path(cl));
lua_setfield(L, -2, "path");
lua_pushstring(L, cl->get_url(cl));
lua_setfield(L, -2, "url");