Documentation ¶
Overview ¶
Package httpreverseproxy provides an HTTP Reverse Proxy that takes an incoming request and sends it to another server, proxying the response back to the client. It wraps the net/http/httputil ReverseProxy with common functionalities. It uses the internal github.com/Vonage/gosrvlib/pkg/logging package ("go.uber.org/zap") for error logs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements the Reverse Proxy.
func (*Client) ForwardRequest ¶
func (c *Client) ForwardRequest(w http.ResponseWriter, r *http.Request)
ForwardRequest forwards a request to the proxied service.
type HTTPClient ¶
HTTPClient contains the function to perform the HTTP request to the proxied service.
type Option ¶
type Option func(c *Client)
Option is the interface that allows to set client options.
func WithHTTPClient ¶
func WithHTTPClient(h HTTPClient) Option
WithHTTPClient overrides the default HTTP client used to forward the requests. The HTTP client can contain extra logic for logging.
func WithReverseProxy ¶
func WithReverseProxy(p *httputil.ReverseProxy) Option
WithReverseProxy overrides the default httputil.ReverseProxy. Leave the Director and Transport entries nil to be automatically set. If the Director entry is specified, then the addr argument of the New function is ignored. If the Transport entry is specified, then the HTTP client specified with WithHTTPClient is ignored.