mirror of
https://github.com/kataras/iris.git
synced 2025-12-20 03:17:04 +00:00
minor fix required for the upcoming release
Former-commit-id: f04b770f93d7612941340af6e45d7d0516035e14
This commit is contained in:
@@ -4,6 +4,7 @@ package handler
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris/v12/context"
|
||||
"github.com/kataras/iris/v12/core/memstore"
|
||||
"github.com/kataras/iris/v12/macro"
|
||||
)
|
||||
|
||||
@@ -76,10 +77,33 @@ func MakeFilter(tmpl macro.Template) context.Filter {
|
||||
return false
|
||||
}
|
||||
|
||||
if !p.Eval(entry.String(), &ctx.Params().Store) {
|
||||
value := p.Eval(entry.String())
|
||||
if value == nil {
|
||||
ctx.StatusCode(p.ErrCode)
|
||||
return false
|
||||
}
|
||||
|
||||
// Fixes binding different path parameters names,
|
||||
//
|
||||
// app.Get("/{fullname:string}", strHandler)
|
||||
// app.Get("/{id:int}", idHandler)
|
||||
//
|
||||
// before that user didn't see anything
|
||||
// but under the hoods the set-ed value was a type of string instead of type of int,
|
||||
// because store contained both "fullname" (which set-ed by the router itself on its string representation)
|
||||
// and "id" by the param evaluator (see core/router/handler.go and bindMultiParamTypesHandler->MakeFilter)
|
||||
// and the MVC get by index (e.g. 0) therefore
|
||||
// it got the "fullname" of type string instead of "id" int if /{int} requested.
|
||||
// which is critical for faster type assertion in the upcoming, new iris dependency injection (20 Feb 2020).
|
||||
ctx.Params().Store[p.Index] = memstore.Entry{
|
||||
Key: p.Name,
|
||||
ValueRaw: value,
|
||||
}
|
||||
|
||||
// for i, v := range ctx.Params().Store {
|
||||
// fmt.Printf("[%d:%s] macro/handler/handler.go: param passed: %s(%v of type: %T)\n", i, v.Key,
|
||||
// p.Src, v.ValueRaw, v.ValueRaw)
|
||||
// }
|
||||
}
|
||||
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user