Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ReverseProxy ¶
type ReverseProxy struct { // Set the timeout of the proxy server, default is 5 minutes Timeout time.Duration // 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. // default is http.DefaultTransport. 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 // ModifyResponse is an optional function that // modifies the Response from the backend. // If it returns an error, the proxy returns a StatusBadGateway error. ModifyResponse func(*http.Response) error }
ReverseProxy is an HTTP Handler that takes an incoming request and sends it to another server, proxying the response back to the client, support http, also support https tunnel using http.hijacker
func NewReverseProxy ¶
func NewReverseProxy(target *url.URL) *ReverseProxy
NewReverseProxy 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. if the target's query is a=10 and the incoming request's query is b=100, the target's request's query will be a=10&b=100. NewReverseProxy does not rewrite the Host header. To rewrite Host headers, use ReverseProxy directly with a custom Director policy.
func (*ReverseProxy) ProxyHTTP ¶
func (p *ReverseProxy) ProxyHTTP(rw http.ResponseWriter, req *http.Request)
func (*ReverseProxy) ProxyHTTPS ¶
func (p *ReverseProxy) ProxyHTTPS(rw http.ResponseWriter, req *http.Request)
func (*ReverseProxy) ServeHTTP ¶
func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)