Documentation ¶
Overview ¶
Package proxy is middleware that proxies requests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HostPool ¶ added in v0.6.0
type HostPool []*UpstreamHost
type LeastConn ¶ added in v0.6.0
type LeastConn struct{}
The least_conn policy selects a host with the least connections. If multiple hosts have the least amount of connections, one is randomly chosen.
func (*LeastConn) Select ¶ added in v0.6.0
func (r *LeastConn) Select(pool HostPool) *UpstreamHost
type Policy ¶ added in v0.6.0
type Policy interface {
Select(pool HostPool) *UpstreamHost
}
Policy decides how a host will be selected from a pool.
type Proxy ¶
type Proxy struct { Next middleware.Handler Upstreams []Upstream }
Proxy represents a middleware instance that can proxy requests.
type Random ¶ added in v0.6.0
type Random struct{}
The random policy randomly selected an up host from the pool.
func (*Random) Select ¶ added in v0.6.0
func (r *Random) Select(pool HostPool) *UpstreamHost
type ReverseProxy ¶ added in v0.6.0
type ReverseProxy struct { // Director must be a function which modifies // the request into a new request to be sent // using Transport. Its response is then copied // back to the original client unmodified. Director func(*http.Request) // The transport used to perform proxy requests. // If nil, http.DefaultTransport is used. Transport http.RoundTripper // FlushInterval specifies the flush interval // to flush to the client while copying the // response body. // If zero, no periodic flushing is done. FlushInterval time.Duration }
ReverseProxy is an HTTP Handler that takes an incoming request and sends it to another server, proxying the response back to the client.
func NewSingleHostReverseProxy ¶ added in v0.6.0
func NewSingleHostReverseProxy(target *url.URL) *ReverseProxy
NewSingleHostReverseProxy returns a new ReverseProxy that rewrites URLs to the scheme, host, and base path provided in target. If the target's path is "/base" and the incoming request was for "/dir", the target request will be for /base/dir.
func (*ReverseProxy) ServeHTTP ¶ added in v0.6.0
func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request, extraHeaders http.Header) error
type RoundRobin ¶ added in v0.6.0
type RoundRobin struct {
Robin uint32
}
The round_robin policy selects a host based on round robin ordering.
func (*RoundRobin) Select ¶ added in v0.6.0
func (r *RoundRobin) Select(pool HostPool) *UpstreamHost
type Upstream ¶ added in v0.6.0
type Upstream interface { //The path this upstream host should be routed on From() string // Selects an upstream host to be routed to. Select() *UpstreamHost }
An upstream manages a pool of proxy upstream hosts. Select should return a suitable upstream host, or nil if no such hosts are available.
type UpstreamHost ¶ added in v0.6.0
type UpstreamHost struct { // The hostname of this upstream host Name string ReverseProxy *ReverseProxy Conns int64 Fails int32 FailTimeout time.Duration Unhealthy bool ExtraHeaders http.Header CheckDown UpstreamHostDownFunc }
An UpstreamHost represents a single proxy upstream
func (*UpstreamHost) Down ¶ added in v0.6.0
func (uh *UpstreamHost) Down() bool
type UpstreamHostDownFunc ¶ added in v0.6.0
type UpstreamHostDownFunc func(*UpstreamHost) bool