接口入口函数首个参数支持custom context

This commit is contained in:
2025-04-12 21:52:07 +08:00
parent a7fed88714
commit e0d5e9c94b
4 changed files with 15 additions and 5 deletions

View File

@ -69,8 +69,9 @@ func (c controller) methodConfig(reflectMethod reflect.Method) (cfg UriConfig, n
needRegister = false
return
}
// 第一个参数必须是 *gin.Context
if methodType.In(1).String() != GinContextType {
// 第一个参数必须是 *gin.Context 或者 *define.Context
paramOne := methodType.In(1).String()
if paramOne != GinContextType && paramOne != CustomContextType {
needRegister = false
return
}
@ -106,6 +107,7 @@ func (c controller) methodConfig(reflectMethod reflect.Method) (cfg UriConfig, n
}
}
// 解析meta信息
cfg.CtxType = paramOne
cfg.Path = metaField.Tag.Get(TagNamePath)
cfg.RequestMethod = metaField.Tag.Get(TagNameMethod)
cfg.Desc = metaField.Tag.Get(TagNameDesc)