Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CharsetOrEncoding ¶
type CharsetOrEncoding struct { Value string Parameters Parameters }
CharsetOrEncoding is s structure to represent charset or encoding with their parameters.
type MatchConneg ¶
type MatchConneg struct { // List of content/mime types to match against ([IETF RFC 7231, section 5.3.2](https://datatracker.ietf.org/doc/html/rfc7231#section-5.3.2)). Default: Empty list MatchTypes []string `json:"match_types,omitempty"` // List of language codes to match against ([IETF RFC 7231, section 5.3.5](https://datatracker.ietf.org/doc/html/rfc7231#section-5.3.5)). Default: Empty list MatchLanguages []string `json:"match_languages,omitempty"` // List of character sets to match against ([IETF RFC 7231, section 5.3.3](https://datatracker.ietf.org/doc/html/rfc7231#section-5.3.3)). Default: Empty list MatchCharsets []string `json:"match_charsets,omitempty"` // List of encodings to match against ([IETF RFC 7231, section 5.3.4](https://datatracker.ietf.org/doc/html/rfc7231#section-5.3.4)). Default: Empty list MatchEncodings []string `json:"match_encodings,omitempty"` // Query string parameter key to override content negotiation. Default: "" ForceTypeQueryString string `json:"force_type_query_string,omitempty"` // Query string parameter key to override language negotiation. Default: "" ForceLanguageQueryString string `json:"force_language_query_string,omitempty"` // Query string parameter key to override charset negotiation. Default: "" ForceCharsetQueryString string `json:"force_charset_query_string,omitempty"` // Query string parameter key to override encoding negotiation. Default: "" ForceEncodingQueryString string `json:"force_encoding_query_string,omitempty"` // Variable name (will be prefixed with `conneg_`) to hold result of content negotiation. Default: "" VarType string `json:"var_type,omitempty"` // Variable name (will be prefixed with `conneg_`) to hold result of language negotiation. Default: "" VarLanguage string `json:"var_language,omitempty"` // Variable name (will be prefixed with `conneg_`) to hold result of charset negotiation. Default: "" VarCharset string `json:"var_charset,omitempty"` // Variable name (will be prefixed with `conneg_`) to hold result of encoding negotiation. Default: "" VarEncoding string `json:"var_encoding,omitempty"` // the following fields are populated internally/computationally MatchTTypes []contenttype.MediaType `json:"omitempty"` MatchTLanguages []language.Tag `json:"omitempty"` MatchTCharsets []CharsetOrEncoding `json:"omitempty"` MatchTEncodings []CharsetOrEncoding `json:"omitempty"` LanguageMatcher language.Matcher `json:"omitempty"` // contains filtered or unexported fields }
MatchConneg matches requests by comparing results of a content negotiation process to a (list of) value(s).
Lists of media types, languages, charsets, and encodings to match the request against can be given - and at least one of them MUST be specified.
OPTIONAL parameters are strings for identifying URL query string parameter keys that allow requests to override/skip the connection negotiation process and force a media type, a language, a charset or an encoding.
Some shorthand values for query string parameters translating to full media types (languages, encodings, etc.) are hardcoded in a variable called `aliases`: They presently cover `htm` and `html` for `text/html`, `text` or `txt` for `text/plain`, `rdf` for `application/rdf+xml`, `tei` and `xml` for `application/tei+xml`, and `pdf` for `application/pdf`. For instance, if `force_type_query_string` is set to `format`, a request uri ending in `foo.com?format=tei` will result in content type `application/tei+xml` and then succeed or not, based on whether that content type is listed in `match_types`.
COMPATIBILITY NOTE: This module is still experimental and is not subject to Caddy's compatibility guarantee.
func (MatchConneg) CaddyModule ¶
func (MatchConneg) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (MatchConneg) Match ¶
func (m MatchConneg) Match(r *http.Request) bool
Match returns true if the request matches all requirements.
func (*MatchConneg) Provision ¶
func (m *MatchConneg) Provision(ctx caddy.Context) error
Provision sets up the module.
func (*MatchConneg) UnmarshalCaddyfile ¶
func (m *MatchConneg) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile implements caddyfile.Unmarshaler.
func (MatchConneg) Validate ¶
func (m MatchConneg) Validate() error
Validate validates that the module has a usable config.
type Parameters ¶
Parameters is a map to represent charset or encoding parameters.