Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultRewriter ¶
DefaultRewriter adjust the *http.Request object it's attributes match those of the destionation url (scheme, host, path, ...)
Types ¶
type Proxy ¶
type Proxy struct {
*ProxyOptions
// contains filtered or unexported fields
}
func New ¶
func New(opts ProxyOptions) (*Proxy, error)
New returns a new Proxy instance based on the provided ProxyOptions either 'Backend' (static) or 'Balancer' must be provided
type ProxyOptions ¶
type ProxyOptions struct {
// Number of times a request should be tried
Retries int
// Period to wait between retries
Period time.Duration
// Returns a url that we should proxy to for a given request
Balancer func(req *http.Request) (string, error)
// A static backend to route to
Backend string
// Rewriter is a function modifying the request before it's proxied
// usually it should change the hostname of the request object, etc ...
Rewriter func(req *http.Request, destUrl *url.URL)
// Allows to customize how errors are written to responses
ErrorHandler func(rw http.ResponseWriter, req *http.Request, err error)
}
Click to show internal directories.
Click to hide internal directories.