Documentation
¶
Overview ¶
Package proxy implements the extensions to a SimpleServer necessary to implement a full HTTP(S) Reverse Proxy.
This package relies heavily on the "server" and "client" packages of this library to perform the actual routing and Request/Response Handling. The primary additional logic of this package is the specific "doReverseProxy" function, making use of a "ReverseProxyRouterFunc".
The high-level idea of how this package operates is that all incoming requests which the proxy server is configured to accept (URI's match the path prefix) will be processed by the given "ReverseProxyRouterFunc". This function must be able to look at the current request and determine the host to forward to from it. This function MUST return the new host to forward to. The proxy server then uses a SimpleClient to actually perform the request, before writing the response back to the original request source.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigureReverseProxy ¶
func ConfigureReverseProxy(S *server.SimpleServer, Client *client.SimpleClient, RouteMatcher ReverseProxyRouterFunc, PathPrefix string, Middlewares ...server.MiddlewareHandler)
ConfigureReverseProxy will convert a freshly created SimpleServer into a ReverseProxy. This will use either the provided SimpleClient (or a default HTTP SimpleClient) to perform the requests. The ReverseProxyRouterFunc defines HOW the routing will be peformed, and must map individual requests to URLs to forward to. The PathPrefix defines the base path to proxy from, with a default of "/" indicating that ALL incoming requests should be proxied. Finally, any middlewares desired can be added, noting that the "MiddlewareDefaultLogger" is applied in all cases.
If No Server or Client are provided, default instances will be generated.
Types ¶
type ReverseProxyRouterFunc ¶
ReverseProxyRouterFunc represents the Type which must be satisfied by any function which defines the per-request routing behaviours. This must map a given request to a specific IP:Port host.