Documentation
¶
Index ¶
- type Intercept
- func (Intercept) CaddyModule() caddy.ModuleInfo
- func (i *Intercept) FinalizeUnmarshalCaddyfile(helper httpcaddyfile.Helper) error
- func (irh *Intercept) Provision(ctx caddy.Context) error
- func (ir Intercept) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error
- func (i *Intercept) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Intercept ¶
type Intercept struct {
// List of handlers and their associated matchers to evaluate
// after successful response generation.
// The first handler that matches the original response will
// be invoked. The original response body will not be
// written to the client;
// it is up to the handler to finish handling the response.
//
// Three new placeholders are available in this handler chain:
// - `{http.intercept.status_code}` The status code from the response
// - `{http.intercept.header.*}` The headers from the response
HandleResponse []caddyhttp.ResponseHandler `json:"handle_response,omitempty"`
// contains filtered or unexported fields
}
Intercept is a middleware that intercepts then replaces or modifies the original response. It can, for instance, be used to implement X-Sendfile/X-Accel-Redirect-like features when using modules like FrankenPHP or Caddy Snake.
EXPERIMENTAL: Subject to change or removal.
func (Intercept) CaddyModule ¶
func (Intercept) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
EXPERIMENTAL: Subject to change or removal.
func (*Intercept) FinalizeUnmarshalCaddyfile ¶
func (i *Intercept) FinalizeUnmarshalCaddyfile(helper httpcaddyfile.Helper) error
FinalizeUnmarshalCaddyfile finalizes the Caddyfile parsing which requires having an httpcaddyfile.Helper to function, to parse subroutes.
EXPERIMENTAL: Subject to change or removal.
func (*Intercept) Provision ¶
Provision ensures that i is set up properly before use.
EXPERIMENTAL: Subject to change or removal.
func (*Intercept) UnmarshalCaddyfile ¶
UnmarshalCaddyfile sets up the handler from Caddyfile tokens. Syntax:
intercept [<matcher>] {
# intercept original responses
@name {
status <code...>
header <field> [<value>]
}
replace_status [<matcher>] <status_code>
handle_response [<matcher>] {
<directives...>
}
}
The FinalizeUnmarshalCaddyfile method should be called after this to finalize parsing of "handle_response" blocks, if possible.
EXPERIMENTAL: Subject to change or removal.