Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Random ¶
type Random struct {
// List of target locations to randomly redirect to.
// Placeholders are supported.
To []string `json:"to,omitempty"`
// HTTP status code for redirect.
// Can be:
// - `301` or `"permanent"`
// - `308`
// - `302` or `"temporary"`
// - `303`
// - `307`
//
// Default to `302`.
Code int `json:"code,omitempty"`
// contains filtered or unexported fields
}
Random redirects to a randomly selected Location from list with code.
Caddyfile syntax:
redir_random [<matcher>] {
to <to> <to>
code <code>
}
This module supports placeholders in the `to` list. The `redir_random` directive comes after the `redir` in the [directive order](https://caddyserver.com/docs/caddyfile/directives#directive-order).
IMPORTANT ¶
This module uses math/rand so might be easily predictable.
func (Random) CaddyModule ¶
func (Random) CaddyModule() caddy.ModuleInfo
CaddyModule implements the github.com/caddyserver/caddy/v2.Module interface.
func (*Random) Provision ¶
Provision implements the github.com/caddyserver/caddy/v2.Provisioner interface. Sets Code to the default "302" if not set.
func (Random) ServeHTTP ¶
ServeHTTP implements github.com/caddyserver/caddy/v2/modules/caddyhttp.MiddlewareHandler.
func (*Random) UnmarshalCaddyfile ¶
UnmarshalCaddyfile implements caddyfile.Unmarshaler. Syntax:
redir_random [<matcher>] {
to <to> <to>
code [<code>]
}
func (*Random) Validate ¶
Validate implements the github.com/caddyserver/caddy/v2.Validator interface.