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) 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) ServeHTTP ¶
func (p *ProxyByPrefix) 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 转发规则
Click to show internal directories.
Click to hide internal directories.