2026-08-19 18:36:28 +02:00
|
|
|
-- soakbean middleware function
|
|
|
|
|
return function(opts)
|
|
|
|
|
opts = opts or {exclude={"^/admin"}}
|
|
|
|
|
return function(req,res,next)
|
|
|
|
|
local pass = false
|
2026-08-24 13:29:35 +02:00
|
|
|
if req.method == "GET" or req.method == "HEAD" then
|
2026-08-19 18:36:28 +02:00
|
|
|
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
|
|
|
|
|
|