mirror of
https://github.com/bunkerity/bunkerized-nginx
synced 2023-12-13 21:30:18 +01:00
Change the way the error page is rendered
This commit is contained in:
parent
2ae37ce8d8
commit
defb2c3336
1 changed files with 16 additions and 40 deletions
|
@ -1,5 +1,5 @@
|
|||
local _M = {}
|
||||
_M.__index = _M
|
||||
local _M = {}
|
||||
_M.__index = _M
|
||||
|
||||
local utils = require "utils"
|
||||
local datastore = require "datastore"
|
||||
|
@ -15,76 +15,52 @@ function _M:init()
|
|||
-- Save default errors into datastore
|
||||
local default_errors = {
|
||||
["400"] = {
|
||||
title = "400 - Bad Request",
|
||||
body1 = "Bad Request",
|
||||
body2 = "400",
|
||||
body3 = "The server did not understand the request."
|
||||
body2 = "The server did not understand the request."
|
||||
},
|
||||
["401"] = {
|
||||
title = "401 - Not Authorized",
|
||||
body1 = "Not Authorized",
|
||||
body2 = "401",
|
||||
body3 = "Valid authentication credentials needed for the target resource."
|
||||
body2 = "Valid authentication credentials needed for the target resource."
|
||||
},
|
||||
["403"] = {
|
||||
title = "403 - Forbidden",
|
||||
body1 = "Forbidden",
|
||||
body2 = "403",
|
||||
body3 = "Access is forbidden to the requested page."
|
||||
body2 = "Access is forbidden to the requested page."
|
||||
},
|
||||
["404"] = {
|
||||
title = "404 - Not Found",
|
||||
body1 = "Not Found",
|
||||
body2 = "404",
|
||||
body3 = "The server cannot find the requested page."
|
||||
body2 = "The server cannot find the requested page."
|
||||
},
|
||||
["405"] = {
|
||||
title = "405 - Method Not Allowed",
|
||||
body1 = "Method Not Allowed",
|
||||
body2 = "405",
|
||||
body3 = "The method specified in the request is not allowed."
|
||||
body2 = "The method specified in the request is not allowed."
|
||||
},
|
||||
["413"] = {
|
||||
title = "413 - Request Entity Too Large",
|
||||
body1 = "Request Entity Too Large",
|
||||
body2 = "413",
|
||||
body3 = "The server will not accept the request, because the request entity is too large."
|
||||
body2 = "The server will not accept the request, because the request entity is too large."
|
||||
},
|
||||
["429"] = {
|
||||
title = "429 - Too Many Requests",
|
||||
body1 = "Too Many Requests",
|
||||
body2 = "429",
|
||||
body3 = "Too many requests sent in a given amount of time, try again later."
|
||||
body2 = "Too many requests sent in a given amount of time, try again later."
|
||||
},
|
||||
["500"] = {
|
||||
title = "500 - Internal Server Error",
|
||||
body1 = "Internal Server Error",
|
||||
body2 = "500",
|
||||
body3 = "The request was not completed. The server met an unexpected condition."
|
||||
body2 = "The request was not completed. The server met an unexpected condition."
|
||||
},
|
||||
["501"] = {
|
||||
title = "501 - Not Implemented",
|
||||
body1 = "Not Implemented",
|
||||
body2 = "501",
|
||||
body3 = "The request was not completed. The server did not support the functionality required."
|
||||
body2 = "The request was not completed. The server did not support the functionality required."
|
||||
},
|
||||
["502"] = {
|
||||
title = "502 - Bad Gateway",
|
||||
body1 = "Bad Gateway",
|
||||
body2 = "502",
|
||||
body3 = "The request was not completed. The server received an invalid response from the upstream server."
|
||||
body2 = "The request was not completed. The server received an invalid response from the upstream server."
|
||||
},
|
||||
["503"] = {
|
||||
title = "503 - Service Unavailable",
|
||||
body1 = "Service Unavailable",
|
||||
body2 = "503",
|
||||
body3 = "The request was not completed. The server is temporarily overloading or down."
|
||||
body2 = "The request was not completed. The server is temporarily overloading or down."
|
||||
},
|
||||
["504"] = {
|
||||
title = "504 - Gateway Timeout",
|
||||
body1 = "Gateway Timeout",
|
||||
body2 = "504",
|
||||
body3 = "The gateway has timed out."
|
||||
body2 = "The gateway has timed out."
|
||||
}
|
||||
}
|
||||
local ok, err = datastore:set("plugin_errors_default_errors", cjson.encode(default_errors))
|
||||
|
@ -118,8 +94,8 @@ function _M.error_html(code)
|
|||
return false, "can't get template from datastore : " .. err
|
||||
end
|
||||
-- Compute template
|
||||
return template:format(default_errors[code].title, default_errors[code].body1, default_errors[code].body2,
|
||||
default_errors[code].body3), "success"
|
||||
return template:format(code .. " - " .. default_errors[code].body1, code, default_errors[code].body1,
|
||||
default_errors[code].body2), "success"
|
||||
end
|
||||
|
||||
return _M
|
||||
|
|
Loading…
Reference in a new issue