Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RotationModeStrings ¶
func RotationModeStrings() []string
RotationModeStrings returns a slice of all rotation modes as strings.
Types ¶
type CodeDescription ¶
type Codes ¶
type Codes map[string]CodeDescription // map[http_code]description
Codes is a map of HTTP codes to their descriptions.
The codes may be written in a non-strict manner. For example, they may be "4xx", "4XX", or "4**". If the map contains both "404" and "4xx" keys, and we search for "404", the "404" key will be returned. However, if we search for "405", "400", or any non-existing code that starts with "4" and its length is 3, the value under the key "4xx" will be retrieved.
The length of the code (in string format) is matter.
func (Codes) Find ¶
func (c Codes) Find(httpCode uint16) (CodeDescription, bool)
Find searches the closest match for the given HTTP code, written in a non-strict manner. Read Codes for more information.
type Config ¶
type Config struct { // Templates hold all templates, with the key being the template name and the value being the template content // in HTML format (Go templates are supported here). Templates templates // Formats contain alternative response formats (e.g., if a client requests a response in one of these formats, // we will render the response using the specified format instead of HTML; Go templates are supported). Formats struct { JSON string XML string PlainText string } // Codes hold descriptions for HTTP codes (e.g., 404: "Not Found / The server can not find the requested page"). Codes Codes // TemplateName is the name of the template to use for rendering error pages. The template must be present in the // Templates map. TemplateName string // ProxyHeaders contains a list of HTTP headers that will be proxied from the incoming request to the // error page response. ProxyHeaders []string // L10n contains localization settings. L10n struct { // Disable the localization of error pages. Disable bool } // DefaultCodeToRender is the code for the default error page to be displayed. It is used when the requested // code is not defined in the incoming request (i.e., the code to render as the index page). DefaultCodeToRender uint16 // RespondWithSameHTTPCode determines whether the response should have the same HTTP status code as the requested // error page. // In other words, if set to true and the requested error page has a code of 404, the HTTP response will also have // a status code of 404. If set to false, the HTTP response will have a status code of 200 regardless of the // requested error page's status code. RespondWithSameHTTPCode bool // RotationMode allows to set the rotation mode for templates to switch between them automatically on startup, // on each request, daily, hourly and so on. RotationMode RotationMode // ShowDetails determines whether to show additional details in the error response, extracted from the // incoming request (if supported by the template). ShowDetails bool // DisableMinification determines whether to disable minification of the rendered content (e.g., HTML, CSS) or not. DisableMinification bool }
type RotationMode ¶
type RotationMode byte
RotationMode represents the rotation mode for templates.
const ( RotationModeDisabled RotationMode = iota // do not rotate templates, default RotationModeRandomOnStartup // pick a random template on startup RotationModeRandomOnEachRequest // pick a random template on each request RotationModeRandomHourly // once an hour switch to a random template RotationModeRandomDaily // once a day switch to a random template )
func ParseRotationMode ¶
func ParseRotationMode[T string | []byte](text T) (RotationMode, error)
ParseRotationMode parses a rotation mode (case is ignored) based on the ASCII representation of the rotation mode. If the provided ASCII representation is invalid an error is returned.
func RotationModes ¶
func RotationModes() []RotationMode
RotationModes returns a slice of all rotation modes.
func (RotationMode) String ¶
func (rm RotationMode) String() string
String returns a human-readable representation of the rotation mode.