proxyKit

package
v3.0.57 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsProxyDialError added in v3.0.23

func IsProxyDialError(err error) bool

IsProxyDialError 代理请求返回的error,是否是因为dial目标地址失败?

func Proxy

func Proxy(w http.ResponseWriter, r *http.Request, targetAddr string, options ...ProxyOption) error

Proxy 代理请求(反向代理,请求转发).

调用此方法就行请求转发前,按照实际场景可以: (1) POST请求,覆盖 request body; (2) 变更请求头(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 WithExtraQueryParams added in v3.0.33

func WithExtraQueryParams(extraQueryParams map[string][]string) ProxyOption

WithExtraQueryParams

PS: (1) WithOverrideQueryParams 和 WithExtraQueryParams 只能二选一. (2) 值不用进行编码处理.

func WithOverrideQueryParams added in v3.0.33

func WithOverrideQueryParams(overrideQueryParams map[string][]string) ProxyOption

WithOverrideQueryParams

PS: (1) WithOverrideQueryParams 和 WithExtraQueryParams 只能二选一. (2) 值不用进行编码处理.

func WithPolyfillHeaders

func WithPolyfillHeaders(polyfillHeaders bool) 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL