Documentation
¶
Overview ¶
Package replaceresponse registers a Caddy HTTP handler module that performs replacements on response bodies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// The list of replacements to make on the response body.
Replacements []*Replacement `json:"replacements,omitempty"`
// If true, perform replacements in a streaming fashion.
// This is more memory-efficient but can remove the
// Content-Length header since knowing the correct length
// is impossible without buffering, and getting it wrong
// can break HTTP/2 streams.
Stream bool `json:"stream,omitempty"`
// Only run replacements on responses that match against this ResponseMmatcher.
Matcher *caddyhttp.ResponseMatcher `json:"match,omitempty"`
// contains filtered or unexported fields
}
Handler manipulates response bodies by performing substring or regex replacements.
func (Handler) CaddyModule ¶
func (Handler) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (*Handler) UnmarshalCaddyfile ¶
UnmarshalCaddyfile implements caddyfile.Unmarshaler. Syntax:
replace [stream | [re] <search> <replace>] {
stream
match {
header Content-Type application/json*
}
[re] <search> <replace>
}
If 're' is specified, the search string will be treated as a regular expression. If 'stream' is specified, the replacement will happen without buffering the whole response body; this might remove the Content-Length header.
type Replacement ¶
type Replacement struct {
// A substring to search for. Mutually exclusive with search_regexp.
Search string `json:"search,omitempty"`
// A regular expression to search for. Mutually exclusive with search.
SearchRegexp string `json:"search_regexp,omitempty"`
// The replacement strings/values. Required.
Replaces []string `json:"replace"`
// contains filtered or unexported fields
}
Replacement is either a substring or regular expression replacement to perform; precisely one must be specified, not both.