consts/request.go

104 lines
3.5 KiB
Go
Raw Normal View History

2024-04-22 11:06:54 +08:00
// Package consts ...
//
// Description : consts ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2024-04-22 11:04
package consts
2024-11-25 14:51:14 +08:00
// 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 {
return true
}
}
return false
}
// 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 {
return true
}
}
return false
}
2024-11-25 14:43:40 +08:00
2024-04-22 11:06:54 +08:00
const (
2024-11-25 14:51:14 +08:00
RequestDataLocationHeader RequestDataLocation = "HEADER" // header
RequestDataLocationCookie RequestDataLocation = "COOKIE" // cookie
RequestDataLocationBody RequestDataLocation = "BODY" // body
RequestDataLocationQuery RequestDataLocation = "QUERY" // query
RequestDataLocationUriPath RequestDataLocation = "URI_PATH" // uri路由一部分
RequestDataLocationStatic RequestDataLocation = "STATIC" // 静态配置的参数
RequestDataLocationCustomConfig RequestDataLocation = "CUSTOM_CONFIG" // 针对接口的一些自定义配置规则
2024-04-22 11:06:54 +08:00
)
2024-06-08 20:45:42 +08:00
const (
2024-11-25 14:51:14 +08:00
ResponseDataLocationHeader ResponseDataLocation = "HEADER" // header
ResponseDataLocationCookie ResponseDataLocation = "COOKIE" // cookie
ResponseDataLocationBody ResponseDataLocation = "BODY" // body
ResponseDataLocationExtension ResponseDataLocation = "EXTENSION" // 扩展信息
2024-12-25 11:07:57 +08:00
ResponseDataLocationBodyRoot ResponseDataLocation = "BODY_ROOT" // 整个body是当前值
2024-06-23 14:01:47 +08:00
)
2024-11-25 14:43:40 +08:00
type RequestDataLocationDesc struct {
2024-11-25 14:51:14 +08:00
Value RequestDataLocation `json:"value"` // 数据位置
Description string `json:"description"` // 数据位置描述
2024-11-25 14:43:40 +08:00
}
type ResponseDataLocationDesc struct {
2024-11-25 14:51:14 +08:00
Value ResponseDataLocation `json:"value"` // 数据位置
Description string `json:"description"` // 数据位置描述
2024-06-23 14:01:47 +08:00
}
var (
2024-11-25 14:43:40 +08:00
RequestDataLocationList = []RequestDataLocationDesc{
2024-06-23 14:01:47 +08:00
{Value: RequestDataLocationHeader, Description: "请求header"},
{Value: RequestDataLocationCookie, Description: "请求cookie"},
{Value: RequestDataLocationBody, Description: "请求body"},
{Value: RequestDataLocationQuery, Description: "请求query"},
{Value: RequestDataLocationUriPath, Description: "请求uri_path"},
{Value: RequestDataLocationStatic, Description: "静态参数配置"},
{Value: RequestDataLocationCustomConfig, Description: "自定义接口处理规则"},
2024-06-23 14:01:47 +08:00
}
2024-11-25 14:43:40 +08:00
ResponseDataLocationList = []ResponseDataLocationDesc{
2024-06-23 14:01:47 +08:00
{Value: ResponseDataLocationHeader, Description: "响应header"},
{Value: ResponseDataLocationCookie, Description: "响应cookie"},
{Value: ResponseDataLocationBody, Description: "响应body"},
{Value: ResponseDataLocationExtension, Description: "响应扩展数据"},
2024-12-25 11:07:57 +08:00
{Value: ResponseDataLocationBodyRoot, Description: "相应整体Body"},
2024-06-23 14:01:47 +08:00
}
2024-06-08 20:45:42 +08:00
)