106 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			106 lines
		
	
	
		
			3.8 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
// Package consts ...
 | 
						|
//
 | 
						|
// Description : consts ...
 | 
						|
//
 | 
						|
// Author : go_developer@163.com<白茶清欢>
 | 
						|
//
 | 
						|
// Date : 2024-04-22 11:04
 | 
						|
package consts
 | 
						|
 | 
						|
// RequestDataLocation 请求数据所在位置
 | 
						|
//
 | 
						|
// Author : go_developer@163.com<白茶清欢>
 | 
						|
//
 | 
						|
// Date : 14:40 2024/11/25
 | 
						|
type RequestDataLocation string
 | 
						|
 | 
						|
func (rdl RequestDataLocation) String() string {
 | 
						|
	return string(rdl)
 | 
						|
}
 | 
						|
 | 
						|
func (rdl RequestDataLocation) MarshalJSON() ([]byte, error) {
 | 
						|
	return []byte(`"` + rdl.String() + `"`), nil
 | 
						|
}
 | 
						|
 | 
						|
func (rdl RequestDataLocation) IsValid() bool {
 | 
						|
	for _, item := range RequestDataLocationList {
 | 
						|
		if item.Value == rdl || item.Value.String() == rdl.String() {
 | 
						|
			return true
 | 
						|
		}
 | 
						|
	}
 | 
						|
	return false
 | 
						|
}
 | 
						|
 | 
						|
const (
 | 
						|
	RequestDataLocationHeader       RequestDataLocation = "HEADER"        // header
 | 
						|
	RequestDataLocationCookie       RequestDataLocation = "COOKIE"        // cookie
 | 
						|
	RequestDataLocationBody         RequestDataLocation = "BODY"          // body
 | 
						|
	RequestDataLocationQuery        RequestDataLocation = "QUERY"         // query
 | 
						|
	RequestDataLocationUriPath      RequestDataLocation = "URI_PATH"      // uri路由一部分
 | 
						|
	RequestDataLocationStatic       RequestDataLocation = "STATIC"        // 静态配置的参数
 | 
						|
	RequestDataLocationAny          RequestDataLocation = "ANY"           // 任意位置,要求服务支持从各种位置自动读取
 | 
						|
	RequestDataLocationCustomConfig RequestDataLocation = "CUSTOM_CONFIG" // 针对接口的一些自定义配置规则
 | 
						|
)
 | 
						|
 | 
						|
// ResponseDataLocation 响应数据所在位置
 | 
						|
//
 | 
						|
// Author : go_developer@163.com<白茶清欢>
 | 
						|
//
 | 
						|
// Date : 14:41 2024/11/25
 | 
						|
type ResponseDataLocation string
 | 
						|
 | 
						|
func (rdl ResponseDataLocation) String() string {
 | 
						|
	return string(rdl)
 | 
						|
}
 | 
						|
 | 
						|
func (rdl ResponseDataLocation) MarshalJSON() ([]byte, error) {
 | 
						|
	return []byte(`"` + rdl.String() + `"`), nil
 | 
						|
}
 | 
						|
 | 
						|
func (rdl ResponseDataLocation) IsValid() bool {
 | 
						|
	for _, item := range ResponseDataLocationList {
 | 
						|
		if item.Value == rdl || item.Value.String() == rdl.String() {
 | 
						|
			return true
 | 
						|
		}
 | 
						|
	}
 | 
						|
	return false
 | 
						|
}
 | 
						|
 | 
						|
const (
 | 
						|
	ResponseDataLocationHeader    ResponseDataLocation = "HEADER"    // header
 | 
						|
	ResponseDataLocationCookie    ResponseDataLocation = "COOKIE"    // cookie
 | 
						|
	ResponseDataLocationBody      ResponseDataLocation = "BODY"      // body
 | 
						|
	ResponseDataLocationExtension ResponseDataLocation = "EXTENSION" // 扩展信息
 | 
						|
	ResponseDataLocationBodyRoot  ResponseDataLocation = "BODY_ROOT" // 整个body是当前值
 | 
						|
)
 | 
						|
 | 
						|
type RequestDataLocationDesc struct {
 | 
						|
	Value       RequestDataLocation `json:"value"`       // 数据位置
 | 
						|
	Description string              `json:"description"` // 数据位置描述
 | 
						|
}
 | 
						|
 | 
						|
type ResponseDataLocationDesc struct {
 | 
						|
	Value       ResponseDataLocation `json:"value"`       // 数据位置
 | 
						|
	Description string               `json:"description"` // 数据位置描述
 | 
						|
}
 | 
						|
 | 
						|
var (
 | 
						|
	RequestDataLocationList = []RequestDataLocationDesc{
 | 
						|
		{Value: RequestDataLocationHeader, Description: "请求header"},
 | 
						|
		{Value: RequestDataLocationCookie, Description: "请求cookie"},
 | 
						|
		{Value: RequestDataLocationBody, Description: "请求body"},
 | 
						|
		{Value: RequestDataLocationQuery, Description: "请求query"},
 | 
						|
		{Value: RequestDataLocationUriPath, Description: "请求uri_path"},
 | 
						|
		{Value: RequestDataLocationAny, Description: "任意位置,要求服务本身支持"},
 | 
						|
		{Value: RequestDataLocationStatic, Description: "静态参数配置"},
 | 
						|
		{Value: RequestDataLocationCustomConfig, Description: "自定义接口处理规则"},
 | 
						|
	}
 | 
						|
	ResponseDataLocationList = []ResponseDataLocationDesc{
 | 
						|
		{Value: ResponseDataLocationHeader, Description: "响应header"},
 | 
						|
		{Value: ResponseDataLocationCookie, Description: "响应cookie"},
 | 
						|
		{Value: ResponseDataLocationBody, Description: "响应body"},
 | 
						|
		{Value: ResponseDataLocationExtension, Description: "响应扩展数据"},
 | 
						|
		{Value: ResponseDataLocationBodyRoot, Description: "相应整体Body"},
 | 
						|
	}
 | 
						|
)
 |