github.com/caddyserver/caddy/v2/modules/caddyhttp/intercept
No package summary is available.
Package
Files: 1. Third party imports: 2. Imports from organisation: 0. Tests: 0. Benchmarks: 0.
Constants
Vars
Types
Intercept
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.
| Field name | Field type | Comment |
|---|---|---|
| HandleResponse |
|
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:
|
| responseMatchers |
|
Holds the named response matchers from the Caddyfile while adapting |
| handleResponseSegments |
|
Holds the handle_response Caddyfile tokens while adapting |
| logger |
|
No comment on field. |
interceptedResponseHandler
TODO: handle status code replacement
EXPERIMENTAL: Subject to change or removal.
| Field name | Field type | Comment |
|---|---|---|
|
No comment on field. | |
| replacer |
|
No comment on field. |
| handler |
|
No comment on field. |
| handlerIndex |
|
No comment on field. |
| statusCode |
|
No comment on field. |
Functions
func (*Intercept) FinalizeUnmarshalCaddyfile
FinalizeUnmarshalCaddyfile finalizes the Caddyfile parsing which requires having an httpcaddyfile.Helper to function, to parse subroutes.
EXPERIMENTAL: Subject to change or removal.
Uses: caddyhttp.ResponseHandler, caddyhttp.ResponseMatcher, caddyhttp.Subroute, httpcaddyfile.ParseSegmentAsSubroute, strings.HasPrefix.func (*Intercept) Provision
Provision ensures that i is set up properly before use.
EXPERIMENTAL: Subject to change or removal.
Uses: fmt.Errorf.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.
Uses: caddyhttp.ParseNamedResponseMatcher, caddyhttp.ResponseHandler, caddyhttp.ResponseMatcher, caddyhttp.WeakString, strings.HasPrefix.func (Intercept) CaddyModule
CaddyModule returns the Caddy module information.
EXPERIMENTAL: Subject to change or removal.
func (Intercept) ServeHTTP
EXPERIMENTAL: Subject to change or removal.
Uses: bytes.Buffer, caddyhttp.NewResponseRecorder, http.Header, http.StatusInternalServerError, strconv.Atoi, strings.Join, zap.Int, zapcore.DebugLevel.func (interceptedResponseHandler) Unwrap
EXPERIMENTAL: Subject to change or removal.
func (interceptedResponseHandler) WriteHeader
EXPERIMENTAL: Subject to change or removal.