Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Proxy ¶
func Proxy(w http.ResponseWriter, r *http.Request, targetAddr string, options ...ProxyOption) error
Proxy 代理请求(反向代理,请求转发).
PS: 转发请求前如果想变更请求头(Request Header),可以在调用此函数前设置请求头.
@param w e.g.ctx.Writer @param r e.g.ctx.Request @param targetAddr e.g."127.0.0.1:12345" @param options 可以不传
func ProxyWithGin ¶
func ProxyWithGin(ctx *gin.Context, targetAddr string, options ...ProxyOption) error
Types ¶
type ProxyOption ¶
type ProxyOption func(opts *proxyOptions)
func WithErrorLogger ¶
func WithErrorLogger(errorLogger *log.Logger) ProxyOption
func WithPolyfillHeaders ¶
func WithPolyfillHeaders(polyfillHeaders bool) ProxyOption
func WithQueryParams ¶
func WithQueryParams(queryParams map[string][]string) ProxyOption
func WithReqUrlPath ¶
func WithReqUrlPath(reqUrlPath *string) ProxyOption
WithReqUrlPath
PS: 如果 当前路由 和 目标路由 一致,可以不配置此项;否则必须配置.
@param reqUrlPath (1) 不带query;
(2) 可以使用 ptrKit.Of() 生成 *string 实例.
func WithScheme ¶
func WithScheme(scheme string) ProxyOption
Click to show internal directories.
Click to hide internal directories.