mirror of
https://github.com/eolinker/apinto
synced 2025-10-27 02:30:50 +08:00
去掉proxy_rewrite校验uri配置,并且弃用scheme
This commit is contained in:
@@ -3,27 +3,17 @@ package proxy_rewrite
|
||||
import "fmt"
|
||||
|
||||
type Config struct {
|
||||
Scheme string `json:"scheme" label:"协议"`
|
||||
Scheme string `json:"scheme" label:"协议(已废弃)"`
|
||||
URI string `json:"uri" label:"路径"`
|
||||
RegexURI []string `json:"regex_uri" label:"正则替换路径(regex_uri)"`
|
||||
RegexURI []string `json:"regex_uri" label:"正则替换路径(regex_uri)" description:"该数组需要配置两个正则,第一个是匹配正则,第二个是替换正则。"`
|
||||
Host string `json:"host" label:"Host"`
|
||||
Headers map[string]string `json:"headers" label:"请求头部"`
|
||||
Headers map[string]string `json:"headers" label:"请求头部" description:"可对转发请求的头部进行新增,修改,删除。配置的kv对,不存在则新增,已存在则进行覆盖重写,但需要注意特殊头部字段只能在后面添加新值而不能覆盖。value为空字符串表示删除。"`
|
||||
}
|
||||
|
||||
func (c *Config) doCheck() error {
|
||||
if c.Scheme == "" {
|
||||
c.Scheme = "http"
|
||||
} else if c.Scheme != "http" && c.Scheme != "https" {
|
||||
return fmt.Errorf(schemeErrInfo, c.Scheme)
|
||||
}
|
||||
|
||||
lenRegURI := len(c.RegexURI)
|
||||
|
||||
// URI和RegexURI至少选填其一
|
||||
if c.URI == "" && lenRegURI == 0 {
|
||||
return fmt.Errorf(uriErrInfo)
|
||||
}
|
||||
|
||||
//RegexURI切片要么为空,要么只有两个值,第一个值为正则匹配值,第二个是用于替换的正则字符串
|
||||
if lenRegURI > 0 && lenRegURI != 2 {
|
||||
return fmt.Errorf(regexpURIErrInfo, c.RegexURI)
|
||||
|
||||
Reference in New Issue
Block a user