iris/hero/param.go
Gerasimos (Makis) Maropoulos 3962710d3d Version 11 released. Read https://github.com/kataras/iris/blob/master/HISTORY.md#su-21-october-2018--v1100
Former-commit-id: fe6305deed00e170bf4d39a12c0644fe686e0a24
2018-10-21 19:20:05 +03:00

27 lines
756 B
Go

package hero
import (
"reflect"
"github.com/kataras/iris/context"
)
// weak because we don't have access to the path, neither
// the macros, so this is just a guess based on the index of the path parameter,
// the function's path parameters should be like a chain, in the same order as
// the caller registers a route's path.
// A context or any value(s) can be in front or back or even between them.
type params struct {
// the next function input index of where the next path parameter
// should be inside the CONTEXT.
next int
}
func (p *params) resolve(index int, typ reflect.Type) (reflect.Value, bool) {
currentParamIndex := p.next
v, ok := context.ParamResolverByTypeAndIndex(typ, currentParamIndex)
p.next = p.next + 1
return v, ok
}