iris/mvc/param.go
Gerasimos (Makis) Maropoulos 5fc24812bc ❤️ awesome and unique features for end-developers are coming...
total refactor of the hero and mvc packages, see README#Next (it's not completed yet)


Former-commit-id: b85ae99cbfe5965ba919c1e15cf4989e787982c0
2020-02-29 14:18:15 +02:00

35 lines
657 B
Go

package mvc
import (
"reflect"
"github.com/kataras/iris/v12/context"
"github.com/kataras/iris/v12/macro"
)
func getPathParamsForInput(startParamIndex int, params []macro.TemplateParam, funcIn ...reflect.Type) (values []reflect.Value) {
if len(funcIn) == 0 || len(params) == 0 {
return
}
consumed := make(map[int]struct{})
for _, in := range funcIn {
for j, param := range params {
if _, ok := consumed[j]; ok {
continue
}
funcDep, ok := context.ParamResolverByTypeAndIndex(in, startParamIndex+param.Index)
if !ok {
continue
}
values = append(values, funcDep)
consumed[j] = struct{}{}
break
}
}
return
}