martian – github.com/google/martian Index | Files | Directories

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

Functions

func Context

func Context(req *http.Request) *session.Context

Context returns the associated context for the request.

func RemoveContext

func RemoveContext(req *http.Request)

RemoveContext removes the context for a given request.

func SetContext

func SetContext(req *http.Request, ctx *session.Context)

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

func (p *Proxy) Closing() bool

Closing returns whether the proxy is in the closing state.

func (*Proxy) Serve

func (p *Proxy) Serve(l net.Listener) error

Serve accepts connections from the listener and handles the requests.

func (*Proxy) SetDownstreamProxy

func (p *Proxy) SetDownstreamProxy(proxyURL *url.URL)

SetDownstreamProxy sets the proxy that receives requests from the upstream proxy.

func (*Proxy) SetMITM

func (p *Proxy) SetMITM(config *mitm.Config)

SetMITM sets the config to use for MITMing of CONNECT requests.

func (*Proxy) SetMux

func (p *Proxy) SetMux(mux *http.ServeMux)

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

func (p *Proxy) SetTimeout(timeout time.Duration)

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

type RequestModifierFunc func(req *http.Request) error

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

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

type ResponseModifierFunc func(res *http.Response) error

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

martian.go noop.go proxy.go response_writer.go

Directories

PathSynopsis
authPackage auth provides filtering support for a martian.Proxy based on auth ID.
bodyPackage body allows for the replacement of message body on responses.
cmd
cmd/proxyproxy is an HTTP/S proxy configurable via an HTTP API.
cookiePackage cookie allows for the modification of cookies on http requests and responses.
corsPackage cors provides CORS support for http.Handlers.
fifo
headerPackage header provides utilities for modifying, filtering, and verifying headers in martian.Proxy.
ipauthPackage ipauth provides a martian.Modifier that sets auth based on IP.
logPackage log provides a universal logger for martian packages.
martianhttpPackage martianhttp provides HTTP handlers for managing the state of a martian.Proxy.
martianlogPackage martianlog provides a Martian modifier that logs the request and response.
martiantestPackage martiantest provides helper utilities for testing modifiers.
martianurlPackage martianurl provides utilities for modifying, filtering, and verifying URLs in martian.Proxy.
messageviewPackage messageview provides no-op snapshots for HTTP requests and responses.
methodPackage method provides utilities for verifying method type in martian.Proxy.
mitmPackage mitm provides tooling for MITMing TLS connections.
parsePackage parse constructs martian modifiers from JSON messages.
pingbackPackage pingback provides verification that specific URLs have been seen by the proxy.
priorityPackage priority allows grouping modifiers and applying them in priority order.
proxyauthPackage proxyauth provides authentication support via the Proxy-Authorization header.
proxyutilPackage proxyutil provides functionality for building proxies.
querystringPackage querystring contains a modifier to rewrite query strings in a request.
sessionPackage session provides contextual information about a single HTTP/S connection and its associated requests and responses.
statusPackage status contains a modifier to rewrite the status code on a response.
verifyPackage verify provides support for using martian modifiers for request and response verifications.
Version
v2.0.0-beta.2+incompatible
Published
Aug 24, 2015
Platform
js/wasm
Imports
16 packages
Last checked
now

Tools for package owners.