Documentation
¶
Index ¶
- func Intercept(handler http.Handler, filter Filter) http.Handler
- type Chain
- type Context
- func AdaptContext(ctx context.Context) Context
- func BackgroundContext() Context
- func Discard(ctx Context, req *http.Request) (*http.Response, Context, error)
- func Fail(ctx Context, req *http.Request, statusCode int, err error) (*http.Response, Context, error)
- func ShortCircuit(ctx Context, req *http.Request, resp *http.Response) (*http.Response, Context, error)
- func WrapContext(ctx context.Context, downstream net.Conn) Context
- type Filter
- type FilterFunc
- type Next
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Chain ¶
type Chain []Filter
Chain is a chain of Filters that acts as an http.Handler.
func Join ¶
Join constructs a new chain of filters that executes the filters in order until it encounters a filter that returns false.
type Context ¶
type Context interface {
context.Context
// DownstreamConn retrieves the downstream connection from the given Context.
DownstreamConn() net.Conn
// RequestNumber indicates how many requests have been received on the current
// connection. The RequestNumber for the first request is 1, for the second is 2
// and so forth.
RequestNumber() int
// IncrementRequestNumber increments the request number by 1 and returns a new
// context.
IncrementRequestNumber() Context
// WithCancel mimics the method on context.Context
WithCancel() (Context, context.CancelFunc)
// WithDeadline mimics the method on context.Context
WithDeadline(deadline time.Time) (Context, context.CancelFunc)
// WithTimeout mimics the method on context.Context
WithTimeout(timeout time.Duration) (Context, context.CancelFunc)
// WithMITMing marks this context as being part of an MITM'ed connection.
WithMITMing() Context
// IsMITMing indicates whether or the proxy is MITMing the current connection.
IsMITMing() bool
// WithValue mimics the method on context.Context
WithValue(key, val interface{}) Context
}
Context is a wrapper for Context that exposes some additional information specific to its use in proxies.
func AdaptContext ¶
AdaptContext adapts a context.Context to the Context interface.
func BackgroundContext ¶
func BackgroundContext() Context
BackgroundContext creates a background Context without an associated connection.
func Discard ¶
Discard discards the given request. Make sure to use this when discarding requests in order to make sure that the request body is read.
func Fail ¶
func Fail(ctx Context, req *http.Request, statusCode int, err error) (*http.Response, Context, error)
Fail fails processing, returning a response with the given status code and description populated from error.
type Filter ¶
type Filter interface {
Apply(ctx Context, req *http.Request, next Next) (*http.Response, Context, error)
}
Filter supports intercepting and modifying http requests and responses
type FilterFunc ¶
FilterFunc adapts a function to a Filter