allow lua to use error pages
This commit is contained in:
parent
2f60d02131
commit
185daf6a08
|
@ -15,10 +15,10 @@ rewrite_by_lua_block {
|
|||
|
||||
-- print error and exit with 500 or exit with response if status is not 200
|
||||
if hnsres_err or (hnsres_res and hnsres_res.status ~= ngx.HTTP_OK) then
|
||||
ngx.status = (hnsres_err and ngx.HTTP_INTERNAL_SERVER_ERROR) or hnsres_res.status
|
||||
ngx.header["content-type"] = "text/plain"
|
||||
ngx.say(hnsres_err or hnsres_res.body)
|
||||
return ngx.exit(ngx.status)
|
||||
-- ngx.status = (hnsres_err and ngx.HTTP_INTERNAL_SERVER_ERROR) or hnsres_res.status
|
||||
-- ngx.header["content-type"] = "text/plain"
|
||||
-- ngx.say(hnsres_err or hnsres_res.body)
|
||||
return ngx.exit((hnsres_err and ngx.HTTP_INTERNAL_SERVER_ERROR) or hnsres_res.status)
|
||||
end
|
||||
|
||||
-- since /hnsres endpoint response is a json, we need to decode it before we access it
|
||||
|
@ -48,10 +48,10 @@ rewrite_by_lua_block {
|
|||
|
||||
-- print error and exit with 500 or exit with response if status is not 200
|
||||
if registry_err or (registry_res and registry_res.status ~= ngx.HTTP_OK) then
|
||||
ngx.status = (registry_err and ngx.HTTP_INTERNAL_SERVER_ERROR) or registry_res.status
|
||||
ngx.header["content-type"] = "text/plain"
|
||||
ngx.say(registry_err or registry_res.body)
|
||||
return ngx.exit(ngx.status)
|
||||
-- ngx.status = (registry_err and ngx.HTTP_INTERNAL_SERVER_ERROR) or registry_res.status
|
||||
-- ngx.header["content-type"] = "text/plain"
|
||||
-- ngx.say(registry_err or registry_res.body)
|
||||
return ngx.exit((registry_err and ngx.HTTP_INTERNAL_SERVER_ERROR) or registry_res.status)
|
||||
end
|
||||
|
||||
-- since /skynet/registry endpoint response is a json, we need to decode it before we access it
|
||||
|
|
|
@ -23,10 +23,10 @@ location / {
|
|||
ngx.var.skylink = match_skylink[1]
|
||||
ngx.var.path = match_skylink[2] or "/"
|
||||
else
|
||||
ngx.status = (err and ngx.HTTP_INTERNAL_SERVER_ERROR) or res.status
|
||||
ngx.header["content-type"] = "text/plain"
|
||||
ngx.say(err or res.body)
|
||||
ngx.exit(ngx.status)
|
||||
-- ngx.status = (err and ngx.HTTP_INTERNAL_SERVER_ERROR) or res.status
|
||||
-- ngx.header["content-type"] = "text/plain"
|
||||
-- ngx.say(err or res.body)
|
||||
ngx.exit((err and ngx.HTTP_INTERNAL_SERVER_ERROR) or res.status)
|
||||
end
|
||||
else
|
||||
local resolved = cjson.decode(res.body)
|
||||
|
|
|
@ -44,18 +44,18 @@ end
|
|||
|
||||
-- handle request exit when access to portal should be restricted to authenticated users only
|
||||
function _M.exit_access_unauthorized(message)
|
||||
ngx.status = ngx.HTTP_UNAUTHORIZED
|
||||
ngx.header["content-type"] = "text/plain"
|
||||
ngx.say(message or "Portal operator restricted access to authenticated users only")
|
||||
return ngx.exit(ngx.status)
|
||||
-- ngx.status = ngx.HTTP_UNAUTHORIZED
|
||||
-- ngx.header["content-type"] = "text/plain"
|
||||
-- ngx.say(message or "Portal operator restricted access to authenticated users only")
|
||||
return ngx.exit(ngx.HTTP_UNAUTHORIZED)
|
||||
end
|
||||
|
||||
-- handle request exit when access to portal should be restricted to subscription users only
|
||||
function _M.exit_access_forbidden(message)
|
||||
ngx.status = ngx.HTTP_FORBIDDEN
|
||||
ngx.header["content-type"] = "text/plain"
|
||||
ngx.say(message or "Portal operator restricted access to users with active subscription only")
|
||||
return ngx.exit(ngx.status)
|
||||
-- ngx.status = ngx.HTTP_FORBIDDEN
|
||||
-- ngx.header["content-type"] = "text/plain"
|
||||
-- ngx.say(message or "Portal operator restricted access to users with active subscription only")
|
||||
return ngx.exit(ngx.HTTP_FORBIDDEN)
|
||||
end
|
||||
|
||||
function _M.accounts_enabled()
|
||||
|
|
Reference in New Issue