Documentation ¶
Index ¶
- func ForwardToHost(w http.ResponseWriter, r *http.Request, errorLog *log.Logger, host string, ...) (err error)
- func ForwardToHostComplexly(w http.ResponseWriter, r *http.Request, errorLog *log.Logger, ...) (err error)
- func ForwardToUrl(w http.ResponseWriter, r *http.Request, errorLog *log.Logger, url string) (err error)
- func NewDirector(targetHost string, options ...DirectorOption) (dewDirector func(req *http.Request), err error)
- func NewSingleHostDirector(target *url.URL) (director func(req *http.Request), err error)
- type DirectorOption
- type ReverseProxy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ForwardToHost ¶
func ForwardToHost(w http.ResponseWriter, r *http.Request, errorLog *log.Logger, host string, options ...DirectorOption) (err error)
ForwardToHost
@param errorLog 可以为nil(但不推荐这么干)
func ForwardToHostComplexly ¶
func ForwardToHostComplexly(w http.ResponseWriter, r *http.Request, errorLog *log.Logger, transport http.RoundTripper, modifyResponse func(*http.Response) error, host string, options ...DirectorOption) (err error)
ForwardToHostComplexly
@param errorLog 可以为nil(但不推荐这么干) @param transport 可以为nil @param modifyResponse 可以为nil
func ForwardToUrl ¶ added in v3.0.903
func ForwardToUrl(w http.ResponseWriter, r *http.Request, errorLog *log.Logger, url string) (err error)
ForwardToUrl 代理请求到目标url.
@param errorLog 可以为nil,即无输出 @param url 目标url
func NewDirector ¶
func NewDirector(targetHost string, options ...DirectorOption) (dewDirector func(req *http.Request), err error)
NewDirector
@param targetHost hostname || hostname:port
Types ¶
type DirectorOption ¶
type DirectorOption func(opts *directorOptions)
func WithExtraQueryParams ¶
func WithExtraQueryParams(extraQueryParams map[string][]string) DirectorOption
func WithOverrideQueryParams ¶
func WithOverrideQueryParams(overrideQueryParams map[string][]string) DirectorOption
func WithRequestUrlPath ¶
func WithRequestUrlPath(requestUrlPath string) DirectorOption
func WithScheme ¶
func WithScheme(scheme string) DirectorOption
type ReverseProxy ¶ added in v3.0.903
type ReverseProxy struct {
*httputil.ReverseProxy
}
func NewReverseProxy ¶ added in v3.0.903
func NewReverseProxy(director func(*http.Request), transport http.RoundTripper, modifyResponse func(*http.Response) error, errLog *log.Logger, errHandler func(http.ResponseWriter, *http.Request, error)) (*ReverseProxy, error)
NewReverseProxy
PS: 对于 httputil.ReverseProxy 结构体,Rewrite 和 Director 只能有一个非nil.
@param director 不能为nil!!! @param transport 可以为nil @param modifyResponse 可以为nil @param errLog 可以为nil @param errHandler 可以为nil
func NewSingleHostReverseProxy ¶
func NewSingleHostReverseProxy(target *url.URL) (*ReverseProxy, error)
NewSingleHostReverseProxy
@param target 不能为nil,否则会panic
func (*ReverseProxy) Forward ¶ added in v3.0.903
func (rp *ReverseProxy) Forward(w http.ResponseWriter, r *http.Request) (err error)
Forward 代理请求.
Click to show internal directories.
Click to hide internal directories.