Documentation ¶
Overview ¶
Package martian provides an HTTP/1.1 proxy with an API for configurable request and response modifiers.
Index ¶
- func Context(req *http.Request) *session.Context
- func RemoveContext(req *http.Request)
- func SetContext(req *http.Request, ctx *session.Context)
- type Proxy
- func (p *Proxy) Close()
- func (p *Proxy) Closing() bool
- func (p *Proxy) Serve(l net.Listener) error
- func (p *Proxy) SetDownstreamProxy(proxyURL *url.URL)
- func (p *Proxy) SetMITM(config *mitm.Config)
- func (p *Proxy) SetMux(mux *http.ServeMux)
- func (p *Proxy) SetRequestModifier(reqmod RequestModifier)
- func (p *Proxy) SetResponseModifier(resmod ResponseModifier)
- func (p *Proxy) SetRoundTripper(rt http.RoundTripper)
- func (p *Proxy) SetTimeout(timeout time.Duration)
- type RequestModifier
- type RequestModifierFunc
- type RequestResponseModifier
- type ResponseModifier
- type ResponseModifierFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RemoveContext ¶
RemoveContext removes the context for a given request.
Types ¶
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy is an HTTP proxy with support for TLS MITM and customizable behavior.
func (*Proxy) Close ¶
func (p *Proxy) Close()
Close sets the proxying to the closing state and waits for all connections to resolve.
func (*Proxy) SetDownstreamProxy ¶
SetDownstreamProxy sets the proxy that receives requests from the upstream proxy.
func (*Proxy) SetMux ¶
SetMux sets the http.ServeMux to use for internal proxy requests. Defaults to http.DefaultServeMux.
func (*Proxy) SetRequestModifier ¶
func (p *Proxy) SetRequestModifier(reqmod RequestModifier)
SetRequestModifier sets the request modifier.
func (*Proxy) SetResponseModifier ¶
func (p *Proxy) SetResponseModifier(resmod ResponseModifier)
SetResponseModifier sets the response modifier.
func (*Proxy) SetRoundTripper ¶
func (p *Proxy) SetRoundTripper(rt http.RoundTripper)
SetRoundTripper sets the http.RoundTripper of the proxy.
func (*Proxy) SetTimeout ¶
SetTimeout sets the request timeout of the proxy.
type RequestModifier ¶
type RequestModifier interface { // ModifyRequest modifies the request. ModifyRequest(req *http.Request) error }
RequestModifier is an interface that defines a request modifier that can be used by a proxy.
type RequestModifierFunc ¶
RequestModifierFunc is an adapter for using a function with the given signature as a RequestModifier.
func (RequestModifierFunc) ModifyRequest ¶
func (f RequestModifierFunc) ModifyRequest(req *http.Request) error
ModifyRequest modifies the request using the given function.
type RequestResponseModifier ¶
type RequestResponseModifier interface { RequestModifier ResponseModifier }
RequestResponseModifier is an interface that is both a ResponseModifier and a RequestModifier.
func Noop ¶
func Noop(id string) RequestResponseModifier
Noop returns a modifier that does not change the request or the response.
type ResponseModifier ¶
type ResponseModifier interface { // ModifyResponse modifies the response. ModifyResponse(res *http.Response) error }
ResponseModifier is an interface that defines a response modifier that can be used by a proxy.
type ResponseModifierFunc ¶
ResponseModifierFunc is an adapter for using a function with the given signature as a ResponseModifier.
func (ResponseModifierFunc) ModifyResponse ¶
func (f ResponseModifierFunc) ModifyResponse(res *http.Response) error
ModifyResponse modifies the response using the given function.
Directories ¶
Path | Synopsis |
---|---|
Package auth provides filtering support for a martian.Proxy based on auth ID.
|
Package auth provides filtering support for a martian.Proxy based on auth ID. |
Package body allows for the replacement of message body on responses.
|
Package body allows for the replacement of message body on responses. |
cmd
|
|
proxy
proxy is an HTTP/S proxy configurable via an HTTP API.
|
proxy is an HTTP/S proxy configurable via an HTTP API. |
Package cookie allows for the modification of cookies on http requests and responses.
|
Package cookie allows for the modification of cookies on http requests and responses. |
Package cors provides CORS support for http.Handlers.
|
Package cors provides CORS support for http.Handlers. |
Package header provides utilities for modifying, filtering, and verifying headers in martian.Proxy.
|
Package header provides utilities for modifying, filtering, and verifying headers in martian.Proxy. |
Package ipauth provides a martian.Modifier that sets auth based on IP.
|
Package ipauth provides a martian.Modifier that sets auth based on IP. |
Package log provides a universal logger for martian packages.
|
Package log provides a universal logger for martian packages. |
Package martianhttp provides HTTP handlers for managing the state of a martian.Proxy.
|
Package martianhttp provides HTTP handlers for managing the state of a martian.Proxy. |
Package martianlog provides a Martian modifier that logs the request and response.
|
Package martianlog provides a Martian modifier that logs the request and response. |
Package martiantest provides helper utilities for testing modifiers.
|
Package martiantest provides helper utilities for testing modifiers. |
Package martianurl provides utilities for modifying, filtering, and verifying URLs in martian.Proxy.
|
Package martianurl provides utilities for modifying, filtering, and verifying URLs in martian.Proxy. |
Package messageview provides no-op snapshots for HTTP requests and responses.
|
Package messageview provides no-op snapshots for HTTP requests and responses. |
Package method provides utilities for verifying method type in martian.Proxy.
|
Package method provides utilities for verifying method type in martian.Proxy. |
Package mitm provides tooling for MITMing TLS connections.
|
Package mitm provides tooling for MITMing TLS connections. |
Package parse constructs martian modifiers from JSON messages.
|
Package parse constructs martian modifiers from JSON messages. |
Package pingback provides verification that specific URLs have been seen by the proxy.
|
Package pingback provides verification that specific URLs have been seen by the proxy. |
Package priority allows grouping modifiers and applying them in priority order.
|
Package priority allows grouping modifiers and applying them in priority order. |
Package proxyauth provides authentication support via the Proxy-Authorization header.
|
Package proxyauth provides authentication support via the Proxy-Authorization header. |
Package proxyutil provides functionality for building proxies.
|
Package proxyutil provides functionality for building proxies. |
Package querystring contains a modifier to rewrite query strings in a request.
|
Package querystring contains a modifier to rewrite query strings in a request. |
Package session provides contextual information about a single HTTP/S connection and its associated requests and responses.
|
Package session provides contextual information about a single HTTP/S connection and its associated requests and responses. |
Package status contains a modifier to rewrite the status code on a response.
|
Package status contains a modifier to rewrite the status code on a response. |
Package verify provides support for using martian modifiers for request and response verifications.
|
Package verify provides support for using martian modifiers for request and response verifications. |