Skip to content

Instantly share code, notes, and snippets.

@leafo
Last active December 30, 2015 13:48
Show Gist options
  • Save leafo/7837657 to your computer and use it in GitHub Desktop.
Save leafo/7837657 to your computer and use it in GitHub Desktop.
local lapis = require("lapis")
local app = lapis.Application()
app:match("/user/:id", function(self)
return "Hello user " .. self.params.id
end)
-- named route
app:match("about", "/about", function()
return "welcome to the about page"
end)
app:get("/item/:id", function()
return { json = { name = "the item" } }
end)
app:post("/item/:id", function(self)
return { redirect_to = self:url_for("about") }
end)
return app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment