1 Star 2 Fork 0

api-go/iris

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
methodfunc.go 1.18 KB
一键复制 编辑 原始数据 按行查看 历史
package methodfunc
import (
"reflect"
"github.com/kataras/iris/context"
"github.com/kataras/iris/core/errors"
)
// MethodFunc the handler function.
type MethodFunc struct {
FuncInfo
// MethodCall fires the actual handler.
// The "ctx" is the current context, helps us to get any path parameter's values.
//
// The "f" is the controller's function which is responsible
// for that request for this http method.
// That function can accept one parameter.
//
// The default callers (and the only one for now)
// are pre-calculated by the framework.
MethodCall func(ctx context.Context, f reflect.Value)
RelPath string
}
// Resolve returns all the method funcs
// necessary information and actions to
// perform the request.
func Resolve(typ reflect.Type) ([]MethodFunc, error) {
r := errors.NewReporter()
var methodFuncs []MethodFunc
infos := fetchInfos(typ)
for _, info := range infos {
parser := newFuncParser(info)
a, err := parser.parse()
if r.AddErr(err) {
continue
}
methodFunc := MethodFunc{
RelPath: a.relPath,
FuncInfo: info,
MethodCall: buildMethodCall(a),
}
methodFuncs = append(methodFuncs, methodFunc)
}
return methodFuncs, r.Return()
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/netscript/iris.git
git@gitee.com:netscript/iris.git
netscript
iris
iris
v8.5.2

搜索帮助