完成路由中间件解析
This commit is contained in:
parent
b14b1ef345
commit
f55dee577d
@ -55,15 +55,23 @@ func parseController(controller any) {
|
||||
routerPrefixFuncType.NumOut() == 1 && // 只能有一个返回值
|
||||
routerPrefixFuncType.Out(0).Kind() == reflect.String { // 返回值必须是字符串
|
||||
routerPrefix = routerPrefixFunc.Func.Call([]reflect.Value{controllerValue})[0].String()
|
||||
// .Call(nil)[0].String()
|
||||
}
|
||||
// 请求组的中间件
|
||||
/*routerMiddlewareFunc := controllerType.MethodByName(MiddlewareFuncName)
|
||||
routerMiddlewareFuncType := routerMiddlewareFunc.Type()
|
||||
if routerMiddlewareFuncType.NumIn() == 0 && // 无需任何参数
|
||||
}
|
||||
// 请求组的中间件
|
||||
middlewareList := make([]gin.HandlerFunc, 0)
|
||||
routerMiddlewareFunc, routerMiddlewareFuncExist := controllerType.MethodByName(MiddlewareFuncName)
|
||||
if routerMiddlewareFuncExist {
|
||||
routerMiddlewareFuncType := routerMiddlewareFunc.Type
|
||||
if routerMiddlewareFuncType.NumIn() == 1 && // 无需任何参数
|
||||
routerMiddlewareFuncType.NumOut() == 1 && // 只能有一个返回值
|
||||
routerMiddlewareFuncType.Out(0).String() == "[]gin.HandlerFunc" { // 返回值必须是gin.HandlerFunc
|
||||
}*/
|
||||
res := routerMiddlewareFunc.Func.Call([]reflect.Value{controllerValue})
|
||||
if !res[0].IsNil() {
|
||||
middlewareList = res[0].Interface().([]gin.HandlerFunc)
|
||||
}
|
||||
}
|
||||
fmt.Println(111, middlewareList)
|
||||
}
|
||||
|
||||
fmt.Println(routerPrefix)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user