Skip to content

Instantly share code, notes, and snippets.

@pta2002
Last active December 2, 2019 23:56
Show Gist options
  • Save pta2002/e79f695146048809a29920cd83b47d54 to your computer and use it in GitHub Desktop.
Save pta2002/e79f695146048809a29920cd83b47d54 to your computer and use it in GitHub Desktop.
local router = (require "fw.router")()
router:any("/", function(req, res)
res.header.content_type = "text/plain"
res:write "hello world"
end)
router:any("/user/:name", function(req, res)
res:write ("hello, " .. name)
end)
router:group("/auth/", function(r)
r:before(function(ctx)
end)
r:any("/login/", function(req)
write "login"
end)
end)
router:plug("/stuff/", router)
return function ()
ngx.say("URL: " .. tostring(ngx.var.uri) .. " METHOD: " .. ngx.var.request_method .. '\n')
router:compile()
router:nginx()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment