Documentation ¶
Index ¶
- func Intercept(handler http.Handler, filter Filter) http.Handler
- type Chain
- type ConnectionState
- func Discard(cs *ConnectionState, req *http.Request) (*http.Response, *ConnectionState, error)
- func Fail(cs *ConnectionState, req *http.Request, statusCode int, err error) (*http.Response, *ConnectionState, error)
- func NewConnectionState(initialReq *http.Request, upstream, downstream net.Conn) *ConnectionState
- func ShortCircuit(cs *ConnectionState, req *http.Request, resp *http.Response) (*http.Response, *ConnectionState, error)
- func (cs *ConnectionState) ClearUpstream()
- func (cs *ConnectionState) Clone() *ConnectionState
- func (cs *ConnectionState) Downstream() net.Conn
- func (cs *ConnectionState) IncrementRequestNumber()
- func (cs *ConnectionState) IsMITMing() bool
- func (cs *ConnectionState) OriginalHost() string
- func (cs *ConnectionState) OriginalURLHost() string
- func (cs *ConnectionState) OriginalURLScheme() string
- func (cs *ConnectionState) RequestAwareRequest() *http.Request
- func (cs *ConnectionState) RequestAwareUpstream() net.Conn
- func (cs *ConnectionState) RequestNumber() int
- func (cs *ConnectionState) SetMITMing(isMITMing bool)
- func (cs *ConnectionState) SetRequestAwareRequest(req *http.Request)
- func (cs *ConnectionState) SetRequestAwareUpstream(upstream net.Conn)
- func (cs *ConnectionState) SetUpstream(upstream net.Conn)
- func (cs *ConnectionState) SetUpstreamAddr(upstreamAddr string)
- func (cs *ConnectionState) Upstream() net.Conn
- func (cs *ConnectionState) UpstreamAddr() string
- 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 ConnectionState ¶
type ConnectionState struct {
// contains filtered or unexported fields
}
ConnectionState holds data about a connection. No data is ever guaranteed to be present - the getter methods, such as ConnectionState.Upstream, may return zero values for missing data.
func Discard ¶
func Discard(cs *ConnectionState, req *http.Request) (*http.Response, *ConnectionState, error)
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(cs *ConnectionState, req *http.Request, statusCode int, err error) (*http.Response, *ConnectionState, error)
Fail fails processing, returning a response with the given status code and description populated from error.
func NewConnectionState ¶
func NewConnectionState(initialReq *http.Request, upstream, downstream net.Conn) *ConnectionState
NewConnectionState creates a new ConnectionState object. Any of the inputs may be nil.
func ShortCircuit ¶
func ShortCircuit(cs *ConnectionState, req *http.Request, resp *http.Response) (*http.Response, *ConnectionState, error)
ShortCircuit is a convenience method for creating short-circuiting responses.
func (*ConnectionState) ClearUpstream ¶
func (cs *ConnectionState) ClearUpstream()
ClearUpstream clears data about the upstream connection such that Upstream and UpstreamAddr return zero values.
func (*ConnectionState) Clone ¶
func (cs *ConnectionState) Clone() *ConnectionState
Clone this object.
func (*ConnectionState) Downstream ¶
func (cs *ConnectionState) Downstream() net.Conn
Downstream returns the downstream connection.
func (*ConnectionState) IncrementRequestNumber ¶
func (cs *ConnectionState) IncrementRequestNumber()
IncrementRequestNumber increments the counter tracking the number of requests on this connection.
func (*ConnectionState) IsMITMing ¶
func (cs *ConnectionState) IsMITMing() bool
IsMITMing returns true if this connection is part of a MITM'd connection.
func (*ConnectionState) OriginalHost ¶
func (cs *ConnectionState) OriginalHost() string
OriginalURLScheme is the value of Host taken from the first request received on this connection.
func (*ConnectionState) OriginalURLHost ¶
func (cs *ConnectionState) OriginalURLHost() string
OriginalURLHost is the value of URL.Host taken from the first request received on this connection.
func (*ConnectionState) OriginalURLScheme ¶
func (cs *ConnectionState) OriginalURLScheme() string
OriginalURLScheme is the value of URL.Scheme taken from the first request received on this connection.
func (*ConnectionState) RequestAwareRequest ¶
func (cs *ConnectionState) RequestAwareRequest() *http.Request
RequestAwareRequest is the request used by RequestAware connections.
func (*ConnectionState) RequestAwareUpstream ¶
func (cs *ConnectionState) RequestAwareUpstream() net.Conn
RequestAwareUpstream is the upstream connection used by RequestAware connections.
func (*ConnectionState) RequestNumber ¶
func (cs *ConnectionState) RequestNumber() int
RequestNumber returns the current request number for this connection.
func (*ConnectionState) SetMITMing ¶
func (cs *ConnectionState) SetMITMing(isMITMing bool)
SetMITMing is used to mark or unmark this connection as part of a MITM'd connection.
func (*ConnectionState) SetRequestAwareRequest ¶
func (cs *ConnectionState) SetRequestAwareRequest(req *http.Request)
SetRequestAwareRequest sets the request used by RequestAware connections.
func (*ConnectionState) SetRequestAwareUpstream ¶
func (cs *ConnectionState) SetRequestAwareUpstream(upstream net.Conn)
SetRequestAwareUpstream sets the upstream connection used by RequestAware connections.
func (*ConnectionState) SetUpstream ¶
func (cs *ConnectionState) SetUpstream(upstream net.Conn)
SetUpstream sets the upstream connection.
func (*ConnectionState) SetUpstreamAddr ¶
func (cs *ConnectionState) SetUpstreamAddr(upstreamAddr string)
SetUpstreamAddr sets the upstream address.
func (*ConnectionState) Upstream ¶
func (cs *ConnectionState) Upstream() net.Conn
Upstream returns the upstream connection.
func (*ConnectionState) UpstreamAddr ¶
func (cs *ConnectionState) UpstreamAddr() string
UpstreamAddr returns the address of the upstream connection.
type Filter ¶
type Filter interface {
Apply(cs *ConnectionState, req *http.Request, next Next) (*http.Response, *ConnectionState, error)
}
Filter supports intercepting and modifying http requests and responses
type FilterFunc ¶
type FilterFunc func(cs *ConnectionState, req *http.Request, next Next) (*http.Response, *ConnectionState, error)
FilterFunc adapts a function to a Filter
func (FilterFunc) Apply ¶
func (ff FilterFunc) Apply(cs *ConnectionState, req *http.Request, next Next) (*http.Response, *ConnectionState, error)
Apply implements the interface Filter
type Next ¶
type Next func(cs *ConnectionState, req *http.Request) (*http.Response, *ConnectionState, error)
Next is a function that's used to indicate that request processing should continue as usual.