Documentation
¶
Index ¶
- Variables
- func CreateOnHTMLRewriteResponse(fn func(origin []byte, res *http.Response) ([]byte, error)) func(*http.Response) error
- func CreateOnInjectScriptsResponse(fn func(origin []byte, res *http.Response) string) func(*http.Response) error
- func NewHTTPError(status int, message string) error
- func ParseHostPort(rawHost string) (string, string)
- type BufferPool
- type Config
- type HTTPError
- type MultiHostsConfig
- type MultiHostsRoute
- type MultiHostsRouteBackend
- type Proxy
- type SingleTargetConfig
Constants ¶
This section is empty.
Variables ¶
var Version = "1.4.1"
Version is the version of this package.
Functions ¶
func CreateOnHTMLRewriteResponse ¶ added in v1.2.1
func CreateOnHTMLRewriteResponse(fn func(origin []byte, res *http.Response) ([]byte, error)) func(*http.Response) error
CreateOnHTMLRewriteResponse create a function to rewrite html response
func CreateOnInjectScriptsResponse ¶ added in v1.2.1
func CreateOnInjectScriptsResponse(fn func(origin []byte, res *http.Response) string) func(*http.Response) error
CreateOnInjectScriptsResponse create a function to inject scripts
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, originReq *http.Request) error
// OnResponse is a function that will be called after the response is received.
OnResponse func(res *http.Response, originReq *http.Request) 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 MultiHostsConfig ¶ added in v1.4.0
type MultiHostsConfig struct {
Routes []MultiHostsRoute `json:"routes"`
}
MultiHostsConfig ...
type MultiHostsRoute ¶ added in v1.4.0
type MultiHostsRoute struct {
Host string `json:"host"`
Backend MultiHostsRouteBackend `json:"backend"`
}
MultiHostsRoute ...
type MultiHostsRouteBackend ¶ added in v1.4.0
type MultiHostsRouteBackend struct {
ServiceProtocol string `json:"service_protocol"`
ServiceName string `json:"service_name"`
ServicePort int64 `json:"service_port"`
// Request
Rewriters rewriter.Rewriters `json:"rewriters"`
Headers http.Header `json:"headers"`
//
ResponseHeaders http.Header `json:"response_headers"`
}
MultiHostsRouteBackend ...
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy is a Powerful HTTP Proxy, inspired by Go Reverse Proxy.
func NewMultiHosts ¶ added in v1.4.0
func NewMultiHosts(cfg *MultiHostsConfig) *Proxy
NewMultiHosts ...
func NewSingleTarget ¶
func NewSingleTarget(target string, cfg ...*SingleTargetConfig) *Proxy
NewSingleTarget creates a new SingleTarget Proxy.
type SingleTargetConfig ¶
type SingleTargetConfig struct {
Rewrites rewriter.Rewriters
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
ChangeOrigin bool
}
SingleTargetConfig is the configuration for SingleTarget.