proxyhandler

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProxyModePrefix = "prefix" //前缀替换,匹配并替换指定前缀
	ProxyModeFix    = "fixed"  //固定地址,完全匹配路由进行转发
)

Variables

This section is empty.

Functions

func ProxyHandler

func ProxyHandler(rules ...ItfProxyMode) gin.HandlerFunc

Types

type ItfProxyMode

type ItfProxyMode interface {
	Match(req *http.Request) bool
	ServeHTTP(rw http.ResponseWriter, req *http.Request)
}

func NewProxy

func NewProxy(rule ProxyRule) ItfProxyMode

func NewProxyGroup

func NewProxyGroup(rules ...ProxyRule) []ItfProxyMode

type ProxyByFixed

type ProxyByFixed struct {
	// contains filtered or unexported fields
}

ProxyByFixed 固定匹配转发

func NewProxyByFixed

func NewProxyByFixed(rule ProxyRule) *ProxyByFixed

func (*ProxyByFixed) Match

func (p *ProxyByFixed) Match(req *http.Request) bool

func (*ProxyByFixed) ServeHTTP

func (p *ProxyByFixed) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type ProxyByPrefix

type ProxyByPrefix struct {
	// contains filtered or unexported fields
}

ProxyByPrefix 根据前缀转发的代理

func NewProxyByPrefix

func NewProxyByPrefix(rule ProxyRule) *ProxyByPrefix

func (*ProxyByPrefix) Match

func (p *ProxyByPrefix) Match(req *http.Request) bool

func (*ProxyByPrefix) ServeHTTP

func (p *ProxyByPrefix) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type ProxyNone

type ProxyNone struct {
}

ProxyNone 空代理

func (*ProxyNone) Match

func (p *ProxyNone) Match(req *http.Request) bool

func (*ProxyNone) ServeHTTP

func (p *ProxyNone) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type ProxyRule added in v1.0.4

type ProxyRule struct {
	Mode string `json:"Mode" yaml:"Mode"` //转发模式

	Match string `json:"Match" yaml:"Match"` //匹配模式,见下面的 ProxyModePrefix/ProxyModeFix

	Forward string `json:"Forward" yaml:"Forward"` //转发目标
	Replace string `json:"Replace" yaml:"Replace"` //替换前缀
}

ProxyRule 转发规则

Jump to

Keyboard shortcuts

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