Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Middleware ¶
Middleware represent a HTTP middleware for all incoming requests
type ModifyRequest ¶ added in v0.1.10
ModifyRequest is the function to adapt the request before proxying it
type ModifyResponse ¶ added in v0.1.10
ModifyResponse is the function to adapt the response before returning it to the user
type PathPrefix ¶ added in v0.1.6
type PathPrefix string
PathPrefix is the prefix of the path to find a match in the request path
type PathPrefixRoutesMap ¶ added in v0.1.6
type PathPrefixRoutesMap map[PathPrefix]TargetHost
PathPrefixRoutesMap is the map of PathPrefixes and TargetHosts to map the available routes for the reverse proxy
func CollectPathPrefixRoutesFromEnvVar ¶ added in v0.1.6
func CollectPathPrefixRoutesFromEnvVar() PathPrefixRoutesMap
CollectPathPrefixRoutesFromEnvVar collects the env vars like: PROXY_RULE_WEATHER_API=/weather/>https://api.weather.com PROXY_RULE_WEATHER_API=/geo/>https://api.geo.com This means that a call to:
https://<proxy-host>/weather/v1/today?zone=EU
will be sent to:
https://api.weather.com/v1/today?zone=EU
type ReverseProxy ¶
type ReverseProxy struct {
// contains filtered or unexported fields
}
ReverseProxy is the instance of the reverse proxy server
func New ¶ added in v0.1.6
func New(routes PathPrefixRoutesMap) *ReverseProxy
New is used to create a new instance of a reverse proxy
func (*ReverseProxy) Start ¶
func (rp *ReverseProxy) Start(port int) error
Start starts the reverse proxy on the specified port
func (*ReverseProxy) WithMiddlewares ¶ added in v0.1.6
func (rp *ReverseProxy) WithMiddlewares(middlewares ...Middleware) *ReverseProxy
WithMiddlewares allows specifying the http middleware to be applied to all routes
func (*ReverseProxy) WithModifyRequest ¶ added in v0.1.10
func (rp *ReverseProxy) WithModifyRequest(mreq ModifyRequest) *ReverseProxy
WithModifyRequest adds a request modifier to the reverse proxy
func (*ReverseProxy) WithModifyResponse ¶ added in v0.1.10
func (rp *ReverseProxy) WithModifyResponse(mresp ModifyResponse) *ReverseProxy
WithModifyResponse adds a response modifier to the reverse proxy
type TargetHost ¶ added in v0.1.6
type TargetHost string
TargetHost is the destination host to which to proxy the whole request after the PathPrefix removal