Error Templates
Error Templates allow you to customize the error pages returned by Otoroshi when something goes wrong (4xx errors, 5xx errors, maintenance mode, build mode, etc.). Each error template is associated with a route or service and provides HTML templates with placeholder variables that are replaced at runtime.
UI page
You can find all error templates here
Properties
serviceId: the identifier of the route or service this error template is attached to (also used as the entity id)name: display name of the error templatedescription: description of the error templatetags: list of tags associated to the error templatemetadata: list of metadata associated to the error templatetemplate40x: the HTML template used for 4xx client error responsestemplate50x: the HTML template used for 5xx server error responsestemplateBuild: the HTML template displayed when the service is under constructiontemplateMaintenance: the HTML template displayed when the service is in maintenance modegenericTemplates: a map of cause-specific templates. The key is a cause identifier (e.g.,errors.service.not.found) and supports regex patterns for matching. These templates take priority over the generictemplate40x/template50xtemplatesmessages: a map of custom messages. Keys can bemessage-{status}(e.g.,message-404) for status-specific messages or cause identifiers (e.g.,errors.service.not.found) for cause-specific messages
Template variables
All HTML templates support the following placeholder variables that are replaced at rendering time:
${message}: the error message (can be overridden by amessagesentry matching the status code)${cause}: the cause of the error (can be overridden by amessagesentry matching the cause id)${otoroshiMessage}: the raw error message from Otoroshi${errorId}: a unique identifier for this error occurrence (useful for support/debugging)${status}: the HTTP status code
Template selection logic
When Otoroshi renders an error page, it selects the template in the following order:
- A matching entry in
genericTemplates(exact match on cause id, then regex match) templateMaintenanceif the cause iserrors.service.in.maintenancetemplateBuildif the cause iserrors.service.under.constructiontemplate40xfor 4xx status codestemplate50xfor 5xx status codes (and as a fallback)
JSON response
When the client requests a JSON response, Otoroshi returns a JSON object with the following fields instead of rendering an HTML template:
{
"otoroshi-error-id": "unique-error-id",
"otoroshi-error": "the error message",
"otoroshi-cause": "the error cause",
"otoroshi-raw-error": "the raw otoroshi message"
}
API
The admin API is available at:
http://otoroshi-api.oto.tools:8080/api/error-templates