package martian
import "github.com/google/martian"
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 Debugf(format string, args ...interface{})
- func Errorf(format string, args ...interface{})
- func Infof(format string, args ...interface{})
- func RemoveContext(req *http.Request)
- func SetContext(req *http.Request, ctx *session.Context)
- type Proxy
- func NewProxy() *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
Functions ¶
func Context ¶
Context returns the associated context for the request.
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf logs a debug message with caller information.
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf logs an error message with caller information.
func Infof ¶
func Infof(format string, args ...interface{})
Infof logs an info message with caller information.
func RemoveContext ¶
RemoveContext removes the context for a given request.
func SetContext ¶
SetContext associates the context with 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 NewProxy ¶
func NewProxy() *Proxy
NewProxy returns a new HTTP proxy.
func (*Proxy) Close ¶
func (p *Proxy) Close()
Close sets the proxying to the closing state and waits for all connections to resolve.
func (*Proxy) Closing ¶
Closing returns whether the proxy is in the closing state.
func (*Proxy) Serve ¶
Serve accepts connections from the listener and handles the requests.
func (*Proxy) SetDownstreamProxy ¶
SetDownstreamProxy sets the proxy that receives requests from the upstream proxy.
func (*Proxy) SetMITM ¶
SetMITM sets the config to use for MITMing of CONNECT requests.
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.
Source Files ¶
log.go martian.go noop.go proxy.go response_writer.go
Directories ¶
Path | Synopsis |
---|---|
auth | Package auth provides filtering support for a martian.Proxy based on auth ID. |
body | Package body allows for the replacement of message body on responses. |
cookie | Package cookie allows for the modification of cookies on http requests and responses. |
cors | Package cors provides CORS support for http.Handlers. |
examples | proxy is a martian.Proxy configurable via HTTP. |
fifo | |
header | Package header provides utilities for modifying, filtering, and verifying headers in martian.Proxy. |
ipauth | Package ipauth provides a martian.Modifier that sets auth based on IP. |
log | Package log provides a Martian modifier that logs the request and response. |
martianhttp | Package martianhttp provides HTTP handlers for managing the state of a martian.Proxy. |
martiantest | Package martiantest provides helper utilities for testing modifiers. |
martianurl | Package martianurl provides utilities for modifying, filtering, and verifying URLs in martian.Proxy. |
method | Package method provides utilities for verifying method type in martian.Proxy. |
mitm | Package mitm provides tooling for MITMing TLS connections. |
parse | Package parse constructs martian modifiers from JSON messages. |
pingback | Package pingback provides verification that specific URLs have been seen by the proxy. |
priority | Package priority allows grouping modifiers and applying them in priority order. |
proxyauth | Package proxyauth provides authentication support via the Proxy-Authorization header. |
proxyutil | Package proxyutil provides functionality for building proxies. |
querystring | Package querystring contains a modifier to rewrite query strings in a request. |
session | Package session provides contextual information about a single HTTP/S connection and its associated requests and responses. |
status | Package status contains a modifier to rewrite the status code on a response. |
verify | Package verify provides support for using martian modifiers for request and response verifications. |
- Version
- v2.0.0-beta+incompatible
- Published
- Aug 14, 2015
- Platform
- js/wasm
- Imports
- 16 packages
- Last checked
- now –
Tools for package owners.