2024-07-20 23:39:25 +08:00
|
|
|
// Package router ...
|
|
|
|
//
|
|
|
|
// Description : router ...
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 2024-07-20 22:57
|
|
|
|
package router
|
|
|
|
|
2024-07-21 18:49:44 +08:00
|
|
|
import "reflect"
|
|
|
|
|
2024-07-20 23:39:25 +08:00
|
|
|
const (
|
|
|
|
PrefixFuncName = "RouterPrefix" // 路由前缀函数名称
|
|
|
|
MiddlewareFuncName = "RouterMiddleware" // 路由中间件函数名称
|
|
|
|
)
|
2024-07-21 16:51:02 +08:00
|
|
|
|
|
|
|
const (
|
2025-02-07 16:10:33 +08:00
|
|
|
TagNamePath = "path" // 接口的请求路径
|
|
|
|
TagNameMethod = "method" // 接口的请求方法
|
|
|
|
TagNameUriTag = "tag" // 接口的tag
|
|
|
|
TagNameDesc = "desc" // 接口的描述
|
|
|
|
TagNameStrict = "strict" // 接口是否为严格模式 : 不配置, 则为严格模式.严格模式 : POST 仅解析 BODY , GET 仅解析 QUERY
|
|
|
|
TagNameBinding = "binding" // gin 内置的验证规则tag
|
|
|
|
TagNameValidate = "validate" // validator v10 默认的验证规则tag
|
|
|
|
TagNameErrMsg = "err" // 验证失败错误信息tag
|
2024-07-21 16:51:02 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// UriConfig 接口配置
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 15:41 2024/7/21
|
|
|
|
type UriConfig struct {
|
2025-02-07 16:10:33 +08:00
|
|
|
Path string `json:"path"` // 接口路由, 必须配置
|
|
|
|
Method string `json:"method"` // 接口请求方法, 必须配置
|
|
|
|
TagList []string `json:"tag_list"` // 接口分组
|
|
|
|
Desc string `json:"desc"` // 接口描述
|
|
|
|
Strict bool `json:"strict"` // 接口是否为严格模式 : 不配置, 则为严格模式.严格模式 : POST 仅解析 BODY , GET 仅解析 QUERY
|
|
|
|
ParamList []UriParam `json:"param_list"` // 参数信息表
|
|
|
|
FormDataType reflect.Type `json:"-"` // 表单数据类型
|
|
|
|
ApiLogicFunc reflect.Method `json:"-"` // 自定义的接口逻辑
|
2024-07-21 16:51:02 +08:00
|
|
|
}
|
2025-01-27 19:46:34 +08:00
|
|
|
|
|
|
|
// UriParam 接口参数配置
|
|
|
|
//
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
//
|
|
|
|
// Date : 15:40 2025/1/27
|
|
|
|
type UriParam struct {
|
2025-02-07 16:10:33 +08:00
|
|
|
Field string `json:"field"` // 结构体字段
|
2025-01-27 19:46:34 +08:00
|
|
|
Name string `json:"name"` // 参数名称
|
|
|
|
Type string `json:"type"` // 参数类型
|
2025-02-07 16:10:33 +08:00
|
|
|
Validate string `json:"validate"` // 验证规则: validator/v10 库
|
|
|
|
ErrorMsg string `json:"error_msg"` // 验证失败的错误信息
|
2025-01-27 19:46:34 +08:00
|
|
|
DisableAutoType bool `json:"disable_auto_type"` // 禁用自动类型转换
|
|
|
|
Sort string `json:"sort"` // 参数读取顺序: 默认 POST : body > query > path GET : query > path > body
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
FieldNameMeta = "Meta" // 元信息字段
|
|
|
|
)
|