Documentation ¶
Index ¶
- Constants
- func CreateMwChain(domain *core.Domain) http.Handler
- func CreatePathMwChain(domain *core.Domain, path *core.Path) http.Handler
- type Base
- func (mw *Base) GetDomain() *core.Domain
- func (mw *Base) GetHandlerType() int8
- func (mw *Base) GetLb() lb.LoadBalance
- func (mw *Base) GetLmt() *limiter.Limiter
- func (mw *Base) GetMt() *core.Metrics
- func (mw *Base) GetPath() *core.Path
- func (mw *Base) Init() func(http.Handler) http.Handler
- func (mw *Base) SetDomain(d *core.Domain)
- func (mw *Base) SetHandlerType(i int8)
- func (mw *Base) SetLb(l lb.LoadBalance)
- func (mw *Base) SetLmt(lmt *limiter.Limiter)
- func (mw *Base) SetMt(mt *core.Metrics)
- func (mw *Base) SetPath(p *core.Path)
- type Baser
- type BlackIpsMw
- type BreakerMw
- type BufferPool
- type GateWay
- type HgwMiddleWare
- type LoggerMw
- type MetricsMw
- type RateLimiterMw
- type RecoverMw
- type RequestCopyMw
- type ReverseProxy
Constants ¶
View Source
const ( DomainHandler = 1 DomainPathHandler = 2 )
View Source
const ( XForwardedFor = "X-Forwarded-For" XRealIP = "X-Real-IP" )
View Source
const ( LbRandom = "RANDOM" LbRoundRobin = "ROUNDROBIN" LbWeightRoundRobin = "WEIGHTROUNDROBIN" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Base ¶
type Base struct { HandlerType int8 Domain *core.Domain Path *core.Path // contains filtered or unexported fields }
func (*Base) GetHandlerType ¶
func (*Base) GetLb ¶
func (mw *Base) GetLb() lb.LoadBalance
func (*Base) SetHandlerType ¶
func (*Base) SetLb ¶
func (mw *Base) SetLb(l lb.LoadBalance)
type BlackIpsMw ¶
type BlackIpsMw struct {
Baser
}
type BufferPool ¶
A BufferPool is an interface for getting and returning temporary byte slices for use by io.CopyBuffer.
type RateLimiterMw ¶
type RateLimiterMw struct {
Baser
}
type RequestCopyMw ¶
type RequestCopyMw struct {
Baser
}
type ReverseProxy ¶
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 must not access the provided Request // after returning. 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 // ErrorLog specifies an optional logger for errors // that occur when attempting to proxy the request. // If nil, logging goes to os.Stderr via the log package's // standard logger. ErrorLog *log.Logger // BufferPool optionally specifies a buffer pool to // get byte slices for use by io.CopyBuffer when // copying HTTP response bodies. BufferPool BufferPool // ModifyResponse is an optional function that modifies the // Response from the backend. It is called if the backend // returns a response at all, with any HTTP status code. // If the backend is unreachable, the optional ErrorHandler is // called without any call to ModifyResponse. // // If ModifyResponse returns an error, ErrorHandler is called // with its error value. If ErrorHandler is nil, its default // implementation is used. ModifyResponse func(*http.Response) error // ErrorHandler is an optional function that handles errors // reaching the backend or errors from ModifyResponse. // // If nil, the default is to log the provided error and return // a 502 Status Bad Gateway response. ErrorHandler func(http.ResponseWriter, *http.Request, error) SuccessHandler func(http.ResponseWriter, *http.Request) }
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 ¶
func NewSingleHostReverseProxy(target *url.URL, path *core.Path) *ReverseProxy
NewSingleHostReverseProxy returns a new ReverseProxy that routes 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. NewSingleHostReverseProxy does not rewrite the Host header. To rewrite Host headers, use ReverseProxy directly with a custom Director policy.
func (*ReverseProxy) ServeHTTP ¶
func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)
Click to show internal directories.
Click to hide internal directories.