Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenAndServeWithRedirect ¶
ListenAndServeWithRedirect enables seamless HTTP -> HTTPS redirect on the same port. This is useful for Hawk so that if someone accesses the :7630 port over HTTP, it'll automagically redirect to HTTPS.
Types ¶
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 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 ¶
func NewSingleHostReverseProxy(target *url.URL, without string, keepalive int) *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. Without logic: target's path is "/", incoming is "/api/messages", without is "/api", then the target request will be for /messages.
func (*ReverseProxy) ServeHTTP ¶
func (rp *ReverseProxy) ServeHTTP(rw http.ResponseWriter, outreq *http.Request, respUpdateFn respUpdateFn) error
ServeHTTP serves the proxied request to the upstream by performing a roundtrip. It is designed to handle websocket connection upgrades as well.
func (*ReverseProxy) UseInsecureTransport ¶
func (rp *ReverseProxy) UseInsecureTransport()
UseInsecureTransport is used to facilitate HTTPS proxying when it is OK for upstream to be using a bad certificate, since this transport skips verification.