intercept

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

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 []kenginehttp.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 Kengine Snake.

EXPERIMENTAL: Subject to change or removal.

func (*Intercept) FinalizeUnmarshalKenginefile

func (i *Intercept) FinalizeUnmarshalKenginefile(helper httpkenginefile.Helper) error

FinalizeUnmarshalKenginefile finalizes the Kenginefile parsing which requires having an httpkenginefile.Helper to function, to parse subroutes.

EXPERIMENTAL: Subject to change or removal.

func (Intercept) KengineModule

func (Intercept) KengineModule() kengine.ModuleInfo

KengineModule returns the Kengine module information.

EXPERIMENTAL: Subject to change or removal.

func (*Intercept) Provision

func (irh *Intercept) Provision(ctx kengine.Context) error

Provision ensures that i is set up properly before use.

EXPERIMENTAL: Subject to change or removal.

func (Intercept) ServeHTTP

func (ir Intercept) ServeHTTP(w http.ResponseWriter, r *http.Request, next kenginehttp.Handler) error

EXPERIMENTAL: Subject to change or removal.

func (*Intercept) UnmarshalKenginefile

func (i *Intercept) UnmarshalKenginefile(d *kenginefile.Dispenser) error

UnmarshalKenginefile sets up the handler from Kenginefile tokens. Syntax:

intercept [<matcher>] {
    # intercept original responses
    @name {
        status <code...>
        header <field> [<value>]
    }
    replace_status [<matcher>] <status_code>
    handle_response [<matcher>] {
        <directives...>
    }
}

The FinalizeUnmarshalKenginefile method should be called after this to finalize parsing of "handle_response" blocks, if possible.

EXPERIMENTAL: Subject to change or removal.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL