25 lines
477 B
Lua
25 lines
477 B
Lua
|
|
-- soakbean middleware function
|
||
|
|
return function(opts)
|
||
|
|
opts = opts or {exclude={"^/admin"}}
|
||
|
|
return function(req,res,next)
|
||
|
|
local pass = false
|
||
|
|
if req.method == "GET" then
|
||
|
|
pass = true
|
||
|
|
else
|
||
|
|
foreach(opts.exclude, function(k,path)
|
||
|
|
if req.url:match(path) then
|
||
|
|
pass = true
|
||
|
|
end
|
||
|
|
end)
|
||
|
|
end
|
||
|
|
if pass then
|
||
|
|
next()
|
||
|
|
else
|
||
|
|
res.status(405)
|
||
|
|
res.body("not allowed")
|
||
|
|
res.send(req,res)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|