mirror of
https://github.com/kataras/iris.git
synced 2026-01-09 13:05:56 +00:00
Version 11 released. Read https://github.com/kataras/iris/blob/master/HISTORY.md#su-21-october-2018--v1100
Former-commit-id: fe6305deed00e170bf4d39a12c0644fe686e0a24
This commit is contained in:
@@ -19,50 +19,8 @@ type params struct {
|
||||
|
||||
func (p *params) resolve(index int, typ reflect.Type) (reflect.Value, bool) {
|
||||
currentParamIndex := p.next
|
||||
v, ok := resolveParam(currentParamIndex, typ)
|
||||
v, ok := context.ParamResolverByTypeAndIndex(typ, currentParamIndex)
|
||||
|
||||
p.next = p.next + 1
|
||||
return v, ok
|
||||
}
|
||||
|
||||
func resolveParam(currentParamIndex int, typ reflect.Type) (reflect.Value, bool) {
|
||||
var fn interface{}
|
||||
|
||||
switch typ.Kind() {
|
||||
case reflect.Int:
|
||||
fn = func(ctx context.Context) int {
|
||||
// the second "ok/found" check is not necessary,
|
||||
// because even if the entry didn't found on that "index"
|
||||
// it will return an empty entry which will return the
|
||||
// default value passed from the xDefault(def) because its `ValueRaw` is nil.
|
||||
entry, _ := ctx.Params().GetEntryAt(currentParamIndex)
|
||||
v, _ := entry.IntDefault(0)
|
||||
return v
|
||||
}
|
||||
case reflect.Int64:
|
||||
fn = func(ctx context.Context) int64 {
|
||||
entry, _ := ctx.Params().GetEntryAt(currentParamIndex)
|
||||
v, _ := entry.Int64Default(0)
|
||||
|
||||
return v
|
||||
}
|
||||
case reflect.Bool:
|
||||
fn = func(ctx context.Context) bool {
|
||||
entry, _ := ctx.Params().GetEntryAt(currentParamIndex)
|
||||
v, _ := entry.BoolDefault(false)
|
||||
return v
|
||||
}
|
||||
case reflect.String:
|
||||
fn = func(ctx context.Context) string {
|
||||
entry, _ := ctx.Params().GetEntryAt(currentParamIndex)
|
||||
// print(entry.Key + " with index of: ")
|
||||
// print(currentParamIndex)
|
||||
// println(" and value: " + entry.String())
|
||||
return entry.String()
|
||||
}
|
||||
default:
|
||||
return reflect.Value{}, false
|
||||
}
|
||||
|
||||
return reflect.ValueOf(fn), true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user