Documentation ¶
Index ¶
- func CreateChainedProxy(name string, logTrace *log.Logger, logDebug *log.Logger, logInfo *log.Logger, ...) http.RoundTripper
- func CreateNewResponse(request *http.Request, content string) *http.Response
- func NewRequestError(response *http.Response) error
- func ReadGzipBody(header *http.Header, body io.ReadCloser) ([]byte, error)
- type ChainContext
- type Middleware
- type RedirectorMiddleware
- type RequestError
- type RequestModifierFunc
- type ResponseModifierFunc
- type RetargetMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateChainedProxy ¶
func CreateChainedProxy(name string, logTrace *log.Logger, logDebug *log.Logger, logInfo *log.Logger, logWarn *log.Logger, logError *log.Logger, Transport http.RoundTripper, middlewares ...Middleware) http.RoundTripper
returns a http.RoundTripper that calls each middleware in order
func CreateNewResponse ¶
func NewRequestError ¶
func ReadGzipBody ¶
utility function that reads the bytes from either a request or a response and returns them. Handles gzip compression if present
Types ¶
type ChainContext ¶
type ChainContext map[interface{}]interface{}
used because the golang context stuff is weird...
type Middleware ¶
type Middleware interface { // Modifies the request RequestModifier(*http.Request, ChainContext) error // Modifies the response ResponseModifier(*http.Response, ChainContext) error }
type RedirectorMiddleware ¶
type RedirectorMiddleware struct { // in-memory holder of cookies to be applied to the session // -> URL is TargetServer Cookies http.CookieJar // If a Location: header is encountered, use this to figure out how to handle it RetargetMap RetargetMap // Remote TargetServer *url.URL // the host:port that the proxy is listening on SourceServer *url.URL // Set this to something to override the UserAgent sent to the remote site UserAgent string }
RedirectorMiddleware is a reverse proxy that hides details from both the source client and the target server
func NewRedirectorMiddleware ¶
func NewRedirectorMiddleware(source *url.URL, target *url.URL) *RedirectorMiddleware
func (*RedirectorMiddleware) RequestModifier ¶
func (this *RedirectorMiddleware) RequestModifier(request *http.Request, ctx ChainContext) error
this implements the http.RoundTripper interface, but we break a lot of the rules as we modify the request significantly
func (*RedirectorMiddleware) ResponseModifier ¶
func (this *RedirectorMiddleware) ResponseModifier(response *http.Response, ctx ChainContext) error
type RequestError ¶
an error that contains a new response to send to the client
func (*RequestError) Error ¶
func (this *RequestError) Error() string
type RequestModifierFunc ¶
type RequestModifierFunc func(*http.Request, ChainContext) error
type ResponseModifierFunc ¶
type ResponseModifierFunc func(*http.Response, ChainContext) error
type RetargetMap ¶
RetargetMap is a map that contains utility functions for retargeting HTTP headers from one server to another -> key is the host without the scheme