Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaddyfileHeaderOp ¶
CaddyfileHeaderOp applies a new header operation according to field, value, and replacement. The field can be prefixed with "+" or "-" to specify adding or removing; otherwise, the value will be set (overriding any previous value). If replacement is non-empty, value will be treated as a regular expression which will be used to search and then replacement will be used to complete the substring replacement; in that case, any + or - prefix to field will be ignored.
Types ¶
type Handler ¶
type Handler struct { Request *HeaderOps `json:"request,omitempty"` Response *RespHeaderOps `json:"response,omitempty"` }
Handler is a middleware which can mutate HTTP headers.
func (Handler) CaddyModule ¶
func (Handler) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
type HeaderOps ¶
type HeaderOps struct { Add http.Header `json:"add,omitempty"` Set http.Header `json:"set,omitempty"` Delete []string `json:"delete,omitempty"` Replace map[string][]Replacement `json:"replace,omitempty"` }
HeaderOps defines some operations to perform on HTTP headers.
func (HeaderOps) ApplyToRequest ¶
ApplyToRequest applies ops to r, specially handling the Host header which the standard library does not include with the header map with all the others. This method mutates r.Host.
type Replacement ¶
type Replacement struct { Search string `json:"search,omitempty"` SearchRegexp string `json:"search_regexp,omitempty"` Replace string `json:"replace,omitempty"` // contains filtered or unexported fields }
Replacement describes a string replacement, either a simple and fast sugbstring search or a slower but more powerful regex search.
type RespHeaderOps ¶
type RespHeaderOps struct { *HeaderOps Require *caddyhttp.ResponseMatcher `json:"require,omitempty"` Deferred bool `json:"deferred,omitempty"` }
RespHeaderOps is like HeaderOps, but optionally deferred until response time.