Skip to content

Instantly share code, notes, and snippets.

@roblabla
Created February 17, 2020 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roblabla/f4ce78604e8aa3fbb7b2d078a73880f6 to your computer and use it in GitHub Desktop.
Save roblabla/f4ce78604e8aa3fbb7b2d078a73880f6 to your computer and use it in GitHub Desktop.
{
// Disable admin for test
"admin": {
"disabled": true
},
"apps": {
"http": {
// Use http to avoid having to provision an ssl cert
"http_port": 4444,
"servers": {
"srv0": {
"listen": [
":4444"
],
// Simple authentication route that will invariably fail (since
// nothing is allowed)
"routes": [{
"handle": [
{
"handler": "static_error",
"status_code": "501"
}
]
}],
// Based on the error code, we either want to redirect or return an
// error.
"errors": {
"routes": [{
// Put status_code in the vars so we can access it from the
// vars matcher
"handle": [{
"handler": "vars",
"status_code": "{http.error.status_code}"
}]
},
// Insert actual error handling routes here
// Restore default behavior if error handling route does not match
{
// If status code is not 401 and not empty, return the error code
// in the response
"match": [{
"not": {
"vars": {
"status_code": ""
}
}
}],
"handle": [{
"handler": "static_response",
"status_code": "{http.error.status_code}"
}],
"terminal": true
},
{
// If status code is empty (e.g. an error other than HandlerError
// was returned), return 500
"handle": [{
"handler": "static_response",
"status_code": "500"
}],
"terminal": true
}]
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment