接口入口函数首个参数支持custom context
This commit is contained in:
@ -86,7 +86,13 @@ func RequestHandler(uriCfg UriConfig) gin.HandlerFunc {
|
||||
if uriCfg.FormDataType.Kind() != reflect.Ptr {
|
||||
inputValue = inputValue.Elem()
|
||||
}
|
||||
resList := uriCfg.ApiLogicFunc.Func.Call([]reflect.Value{uriCfg.ApiStructValue, reflect.ValueOf(ctx), inputValue})
|
||||
var firstParam reflect.Value
|
||||
if uriCfg.CtxType == define.CustomContextKey {
|
||||
firstParam = reflect.ValueOf(ctx.MustGet(define.CustomContextKey))
|
||||
} else {
|
||||
firstParam = reflect.ValueOf(ctx)
|
||||
}
|
||||
resList := uriCfg.ApiLogicFunc.Func.Call([]reflect.Value{uriCfg.ApiStructValue, firstParam, inputValue})
|
||||
if resList[1].IsNil() {
|
||||
// 请求成功
|
||||
isSuccess = true
|
||||
|
Reference in New Issue
Block a user