Documentation ¶
Index ¶
- type ExtraPlaceholders
- func (ExtraPlaceholders) CaddyModule() caddy.ModuleInfo
- func (e *ExtraPlaceholders) Provision(ctx caddy.Context) error
- func (e ExtraPlaceholders) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error
- func (e *ExtraPlaceholders) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- func (e *ExtraPlaceholders) Validate() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExtraPlaceholders ¶
type ExtraPlaceholders struct { // RandIntMin defines the minimum value (inclusive) for the `{extra.rand.int}` placeholder. RandIntMin int `json:"rand_int_min,omitempty"` // RandIntMax defines the maximum value (inclusive) for the `{extra.rand.int}` placeholder. RandIntMax int `json:"rand_int_max,omitempty"` // TimeFormatCustom specifies a custom time format for the `{extra.time.now.custom}` and `{extra.time.now.utc.custom}` placeholder. // If left empty, a default format of "2006-01-02 15:04:05" is used. TimeFormatCustom string `json:"time_format_custom,omitempty"` // contains filtered or unexported fields }
ExtraPlaceholders provides additional placeholders that can be used within Caddy configurations:
Placeholder | Description ------------|------------- `{extra.caddy.version.simple}` | Simple version information of the Caddy server (e.g., v2.8.4). `{extra.caddy.version.full}` | Full version information of the Caddy server (e.g., v2.8.4 h1:q3pe...k=). `{extra.rand.float}` | Random float value between 0.0 and 1.0. `{extra.rand.int}` | Random integer value between the configured min and max (default is 0 to 100). `{extra.loadavg.1}` | System load average over the last 1 minute. `{extra.loadavg.5}` | System load average over the last 5 minutes. `{extra.loadavg.15}` | System load average over the last 15 minutes. `{extra.hostinfo.uptime}` | System uptime in a human-readable format. `{extra.newline}` | Newline character (\n).
Current local time placeholders:
Placeholder | Description ------------|------------- `{extra.time.now.month}` | Current month as an integer (e.g., 5 for May). `{extra.time.now.month_padded}` | Current month as a zero-padded string (e.g., "05" for May). `{extra.time.now.day}` | Current day of the month as an integer. `{extra.time.now.day_padded}` | Current day of the month as a zero-padded string. `{extra.time.now.hour}` | Current hour in 24-hour format as an integer. `{extra.time.now.hour_padded}` | Current hour in 24-hour format as a zero-padded string. `{extra.time.now.minute}` | Current minute as an integer. `{extra.time.now.minute_padded}` | Current minute as a zero-padded string. `{extra.time.now.second}` | Current second as an integer. `{extra.time.now.second_padded}` | Current second as a zero-padded string. `{extra.time.now.timezone_offset}` | Current timezone offset from UTC (e.g., +0200). `{extra.time.now.timezone_name}` | Current timezone abbreviation (e.g., CEST). `{extra.time.now.iso_week}` | Current ISO week number of the year. `{extra.time.now.iso_year}` | ISO year corresponding to the current ISO week. `{extra.time.now.weekday_int}` | Current day of the week as an integer (Sunday = 0, Monday = 1, ..., Saturday = 6). `{extra.time.now.custom}` | Current time in a custom format, configurable via the `time_format_custom` directive.
UTC equivalents of the current time placeholders (with `.utc` added):
Placeholder | Description ------------|------------- `{extra.time.now.utc.month}` | Current month in UTC as an integer (e.g., 5 for May). `{extra.time.now.utc.month_padded}` | Current month in UTC as a zero-padded string (e.g., "05" for May). `{extra.time.now.utc.day}` | Current day of the month in UTC as an integer. `{extra.time.now.utc.day_padded}` | Current day of the month in UTC as a zero-padded string. `{extra.time.now.utc.hour}` | Current hour in UTC in 24-hour format as an integer. `{extra.time.now.utc.hour_padded}` | Current hour in UTC in 24-hour format as a zero-padded string. `{extra.time.now.utc.minute}` | Current minute in UTC as an integer. `{extra.time.now.utc.minute_padded}` | Current minute in UTC as a zero-padded string. `{extra.time.now.utc.second}` | Current second in UTC as an integer. `{extra.time.now.utc.second_padded}` | Current second in UTC as a zero-padded string. `{extra.time.now.utc.timezone_offset}` | UTC timezone offset (always +0000). `{extra.time.now.utc.timezone_name}` | UTC timezone abbreviation (always UTC). `{extra.time.now.utc.iso_week}` | Current ISO week number of the year in UTC. `{extra.time.now.utc.iso_year}` | ISO year corresponding to the current ISO week in UTC. `{extra.time.now.utc.weekday_int}` | Current day of the week in UTC as an integer (Sunday = 0, Monday = 1, ..., Saturday = 6). `{extra.time.now.utc.custom}` | Current UTC time in a custom format, configurable via the `time_format_custom` directive.
func (ExtraPlaceholders) CaddyModule ¶
func (ExtraPlaceholders) CaddyModule() caddy.ModuleInfo
CaddyModule returns the module information required by Caddy to register the plugin.
func (*ExtraPlaceholders) Provision ¶ added in v0.3.0
func (e *ExtraPlaceholders) Provision(ctx caddy.Context) error
Provision sets up the module. It is called once the module is instantiated.
func (ExtraPlaceholders) ServeHTTP ¶
func (e ExtraPlaceholders) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error
ServeHTTP adds new placeholders and passes the request to the next handler in the chain.
func (*ExtraPlaceholders) UnmarshalCaddyfile ¶
func (e *ExtraPlaceholders) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile processes the configuration from the Caddyfile.
func (*ExtraPlaceholders) Validate ¶ added in v0.3.0
func (e *ExtraPlaceholders) Validate() error
Validate ensures the configuration is correct.