Documentation
¶
Index ¶
Constants ¶
const HeaderXForwardedFor = "X-Forwarded-For"
HeaderXForwardedFor is the header name for X-Forwarded-For
const HeaderXForwardedHost = "X-Forwarded-Host"
HeaderXForwardedHost is the header name for X-Forwarded-Host
const HeaderXForwardedPort = "X-Forwarded-Port"
HeaderXForwardedPort is the header name for X-Forwarded-Port
const HeaderXForwardedProto = "X-Forwarded-Proto"
HeaderXForwardedProto is the header name for X-Forwarded-Proto
Variables ¶
var Version = "1.1.0"
Version is the version of this package.
Functions ¶
func NewHTTPError ¶
NewHTTPError creates a new HTTPError.
func ParseHostPort ¶
ParseHostPort parses host and port from a string in the form host[:port].
Types ¶
type BufferPool ¶
A BufferPool is an interface for getting and returning temporary byte slices for use by io.CopyBuffer.
type Config ¶
type Config struct {
// IsAnonymouse is a flag to indicate whether the proxy is anonymouse.
// which means the proxy will not add headers:
// X-Forwarded-For
// X-Forwarded-Proto
// X-Forwarded-Host
// X-Forwarded-Port
// Default is false.
IsAnonymouse bool
// OnRequest is a function that will be called before the request is sent.
OnRequest func(req *http.Request) error
// OnResponse is a function that will be called after the response is received.
OnResponse func(res *http.Response) error
// OnError is a function that will be called when an error occurs.
OnError func(err error, rw http.ResponseWriter, req *http.Request)
}
Config is the configuration for the Proxy.
type HTTPError ¶
type HTTPError struct {
// contains filtered or unexported fields
}
HTTPError is an error that wraps an HTTP status code.
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy is a Powerful HTTP Proxy, inspired by Go Reverse Proxy.
func NewSingleTarget ¶
func NewSingleTarget(target string, cfg ...*SingleTargetConfig) *Proxy
NewSingleTarget creates a new SingleTarget Proxy.
type SingleTargetConfig ¶
type SingleTargetConfig struct {
Rewrites map[string]string
Scheme string
Query url.Values
RequestHeaders http.Header
ResponseHeaders http.Header
OnRequest func(req *http.Request) error
OnResponse func(res *http.Response) error
//
IsAnonymouse bool
}
SingleTargetConfig is the configuration for SingleTarget.