wlua is a web framework for Lua that is as simple as it is powerful.
local wlua = require "wlua"
local app = wlua:default()
app:get("/", function (c)
c:send("Hello wlua!")
end)
app:run()
Build skynet need gcc 4.9+
.
Then install use this commond:
git clone https://github.com/hanxi/wlua
cd wlua
sudo make install
WLUA_HOME
and WLUA_BIN
are supported by Makefile, so the following command could be used to customize installation, default WLUA_HOME
is /usr/local/wlua
and WLUA_BIN
is /usr/local/bin/wlua
:
make install WLUA_HOME=/usr/local/wlua WLUA_BIN=/usr/local/bin/wlua
So, need /usr/local/bin
in $PATH
.
- Routing use lua-rax
- Middleware support
- Group router support
- Easy to build HTTP APIs, web site, or single page applications
A quick way to get started with wlua is to utilize the executable cli tool wlua
to generate an scaffold application.
wlua
commond is installed with wlua framework. it looks like:
$ wlua help
wlua 0.0.2, a web framework for Lua that is as simple as it is powerful.
Usage: wlua COMMAND [OPTIONS]
Commands:
new <name> Create a new application
start Start the server
stop Stop the server
reload Reload the server
version Show version of wlua
help Show help tips
Create app:
$ wlua new wlua_demo
Start server:
$ cd wlua_demo
$ wlua start
Visit http://localhost:8081 . Or use curl
test:
curl -i http://localhost:8081
More examples in wlua-examples
local wlua = require "wlua"
-- Creates a wlua router with default logger middleware.
local app = wlua:default()
app:get("/someget", function (c)
c:send("someget")
end)
app:post("/somepost", function (c)
c:send("somepost")
end)
app:put("/someput", function (c)
c:send("someput")
end)
app:delete("/somedelete", function (c)
c:send("somedelete")
end)
app:patch("/somepatch", function (c)
c:send("somepatch")
end)
app:head("/somehead", function (c)
c:send("somehead")
end)
app:options("/someoptions", function (c)
c:send("someoptions")
end)
-- By default it serves on :8081
app:run()
use skynet service_provider create uniqservice
- More test in demo: https://github.com/hanxi/wlua-demo
- Try wlua with docker compose: https://github.com/hanxi/docker-compose-wlua
- More page in blog: http://blog.hanxi.cc/p/74/
- A tools for monitor skyent cluster https://github.com/hanxi/skynet-admin