feat: update comment
This commit is contained in:
@@ -15,20 +15,20 @@ const (
|
|||||||
PrefixFuncName = "RouterPrefix" // 路由前缀函数名称
|
PrefixFuncName = "RouterPrefix" // 路由前缀函数名称
|
||||||
MiddlewareFuncName = "RouterMiddleware" // 路由中间件函数名称
|
MiddlewareFuncName = "RouterMiddleware" // 路由中间件函数名称
|
||||||
GinContextType = "*gin.Context" // gin context 类型名称
|
GinContextType = "*gin.Context" // gin context 类型名称
|
||||||
ErrorType = "error" // error类型
|
ErrorType = "error" // error 类型
|
||||||
ErrorInterfaceFuncName = "Error" // error接口需要实现的方法名称
|
ErrorInterfaceFuncName = "Error" // error 接口需要实现的方法名称
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TagNamePath = "path" // 接口的请求路径
|
TagNamePath = "path" // 接口的请求路径
|
||||||
TagNameMethod = "method" // 接口的请求方法
|
TagNameMethod = "method" // 接口的请求方法
|
||||||
TagNameUriTag = "tag" // 接口的tag
|
TagNameUriTag = "tag" // 接口的 tag
|
||||||
TagNameDesc = "desc" // 接口的描述
|
TagNameDesc = "desc" // 接口的描述
|
||||||
TagNameOutputStrict = "output_strict" // 接口数据是否为严格模式 : 严格模式, 响应数据必须是结构体/map,非严格模式返回任意值
|
TagNameOutputStrict = "output_strict" // 接口数据是否为严格模式 : 严格模式, 响应数据必须是结构体/map,非严格模式返回任意值
|
||||||
TagNameHookSync = "hook-sync" // hook同步执行
|
TagNameHookSync = "hook-sync" // hook 同步执行
|
||||||
TagNameBinding = "binding" // gin 内置的验证规则tag
|
TagNameBinding = "binding" // gin 内置的验证规则tag
|
||||||
TagNameValidate = "validate" // validator v10 默认的验证规则tag
|
TagNameValidate = "validate" // validator v10 默认的验证规则tag
|
||||||
TagNameErrMsg = "err" // 验证失败错误信息tag
|
TagNameErrMsg = "err" // 验证失败错误信息 tag
|
||||||
)
|
)
|
||||||
|
|
||||||
// UriConfig 接口配置
|
// UriConfig 接口配置
|
||||||
|
|||||||
@@ -18,10 +18,6 @@ import (
|
|||||||
type SetServerOptionFunc func(so *serverOption)
|
type SetServerOptionFunc func(so *serverOption)
|
||||||
|
|
||||||
// serverOption 获取server实例的选项
|
// serverOption 获取server实例的选项
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 17:28 2025/2/18
|
|
||||||
type serverOption struct {
|
type serverOption struct {
|
||||||
swaggerUiTheme string // swagger 主题
|
swaggerUiTheme string // swagger 主题
|
||||||
swaggerBaseUri string // swagger基础path
|
swaggerBaseUri string // swagger基础path
|
||||||
@@ -60,10 +56,6 @@ func WithInitContextData(formatFunc func(ctx *gin.Context) map[string]any) SetSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithSwaggerUITheme 设置swaggerUI主题
|
// WithSwaggerUITheme 设置swaggerUI主题
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 17:29 2025/2/18
|
|
||||||
func WithSwaggerUITheme(uiTheme string) SetServerOptionFunc {
|
func WithSwaggerUITheme(uiTheme string) SetServerOptionFunc {
|
||||||
return func(so *serverOption) {
|
return func(so *serverOption) {
|
||||||
uiTheme = strings.TrimSpace(uiTheme)
|
uiTheme = strings.TrimSpace(uiTheme)
|
||||||
@@ -75,10 +67,6 @@ func WithSwaggerUITheme(uiTheme string) SetServerOptionFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithGlobalMiddlewareList 设置全局中间件
|
// WithGlobalMiddlewareList 设置全局中间件
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 17:33 2025/2/18
|
|
||||||
func WithGlobalMiddlewareList(middlewareList ...gin.HandlerFunc) SetServerOptionFunc {
|
func WithGlobalMiddlewareList(middlewareList ...gin.HandlerFunc) SetServerOptionFunc {
|
||||||
return func(so *serverOption) {
|
return func(so *serverOption) {
|
||||||
so.globalMiddlewareList = middlewareList
|
so.globalMiddlewareList = middlewareList
|
||||||
@@ -86,10 +74,6 @@ func WithGlobalMiddlewareList(middlewareList ...gin.HandlerFunc) SetServerOption
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithSwaggerBaseUri ...
|
// WithSwaggerBaseUri ...
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 18:05 2025/2/18
|
|
||||||
func WithSwaggerBaseUri(baseUri string) SetServerOptionFunc {
|
func WithSwaggerBaseUri(baseUri string) SetServerOptionFunc {
|
||||||
return func(so *serverOption) {
|
return func(so *serverOption) {
|
||||||
baseUri = strings.TrimSpace(baseUri)
|
baseUri = strings.TrimSpace(baseUri)
|
||||||
@@ -102,10 +86,6 @@ func WithSwaggerBaseUri(baseUri string) SetServerOptionFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithDisableSwaggerDoc 禁用swagger文档
|
// WithDisableSwaggerDoc 禁用swagger文档
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 17:35 2025/2/18
|
|
||||||
func WithDisableSwaggerDoc() SetServerOptionFunc {
|
func WithDisableSwaggerDoc() SetServerOptionFunc {
|
||||||
return func(so *serverOption) {
|
return func(so *serverOption) {
|
||||||
so.disableSwaggerDoc = true
|
so.disableSwaggerDoc = true
|
||||||
@@ -113,10 +93,6 @@ func WithDisableSwaggerDoc() SetServerOptionFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithServerInfo 设置serverInfo
|
// WithServerInfo 设置serverInfo
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 17:51 2025/2/18
|
|
||||||
func WithServerInfo(serverInfo *apiDocDefine.Info) SetServerOptionFunc {
|
func WithServerInfo(serverInfo *apiDocDefine.Info) SetServerOptionFunc {
|
||||||
return func(so *serverOption) {
|
return func(so *serverOption) {
|
||||||
if nil == serverInfo {
|
if nil == serverInfo {
|
||||||
@@ -127,10 +103,6 @@ func WithServerInfo(serverInfo *apiDocDefine.Info) SetServerOptionFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithServerList 设置服务器列表
|
// WithServerList 设置服务器列表
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 17:52 2025/2/18
|
|
||||||
func WithServerList(serverList []*apiDocDefine.ServerItem) SetServerOptionFunc {
|
func WithServerList(serverList []*apiDocDefine.ServerItem) SetServerOptionFunc {
|
||||||
return func(so *serverOption) {
|
return func(so *serverOption) {
|
||||||
if len(serverList) == 0 {
|
if len(serverList) == 0 {
|
||||||
@@ -141,10 +113,6 @@ func WithServerList(serverList []*apiDocDefine.ServerItem) SetServerOptionFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithPprofEnable 启用pprof
|
// WithPprofEnable 启用pprof
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 15:10 2025/2/21
|
|
||||||
func WithPprofEnable() SetServerOptionFunc {
|
func WithPprofEnable() SetServerOptionFunc {
|
||||||
return func(so *serverOption) {
|
return func(so *serverOption) {
|
||||||
so.enablePprof = true
|
so.enablePprof = true
|
||||||
@@ -152,10 +120,6 @@ func WithPprofEnable() SetServerOptionFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithEnableCors 启用全局跨域
|
// WithEnableCors 启用全局跨域
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 14:56 2025/2/22
|
|
||||||
func WithEnableCors() SetServerOptionFunc {
|
func WithEnableCors() SetServerOptionFunc {
|
||||||
return func(so *serverOption) {
|
return func(so *serverOption) {
|
||||||
so.enableCors = true
|
so.enableCors = true
|
||||||
@@ -163,10 +127,6 @@ func WithEnableCors() SetServerOptionFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithLoggerCfg ...
|
// WithLoggerCfg ...
|
||||||
//
|
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
|
||||||
//
|
|
||||||
// Date : 15:25 2025/2/22
|
|
||||||
func WithLoggerCfg(loggerCfg *middleware.AccessConfig) SetServerOptionFunc {
|
func WithLoggerCfg(loggerCfg *middleware.AccessConfig) SetServerOptionFunc {
|
||||||
return func(so *serverOption) {
|
return func(so *serverOption) {
|
||||||
if nil != loggerCfg || nil != loggerCfg.Logger {
|
if nil != loggerCfg || nil != loggerCfg.Logger {
|
||||||
|
|||||||
Reference in New Issue
Block a user