forked from kataras/iris
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparam.go
More file actions
26 lines (21 loc) · 756 Bytes
/
param.go
File metadata and controls
26 lines (21 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
}