1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-20 03:17:04 +00:00
This commit is contained in:
Gerasimos (Makis) Maropoulos
2022-04-18 10:52:47 +03:00
parent e98c21d1c5
commit 1e5cbf9e24
3 changed files with 7 additions and 4 deletions

View File

@@ -16,7 +16,7 @@ func init() {
} }
if setting.Key == "vcs.time" { if setting.Key == "vcs.time" {
BuildTime = setting.Key BuildTime = setting.Value
} }
} }
} }

View File

@@ -43,7 +43,8 @@ func convertMacroTmplToNodePath(tmpl macro.Template) string {
// if it has started with {} and it's valid // if it has started with {} and it's valid
// then the tmpl.Params will be filled, // then the tmpl.Params will be filled,
// so no any further check needed. // so no any further check needed.
for _, p := range tmpl.Params { for i := range tmpl.Params {
p := tmpl.Params[i]
if ast.IsTrailing(p.Type) { if ast.IsTrailing(p.Type) {
routePath = strings.Replace(routePath, p.Src, WildcardParam(p.Name), 1) routePath = strings.Replace(routePath, p.Src, WildcardParam(p.Name), 1)
} else { } else {

View File

@@ -36,7 +36,8 @@ func CanMakeHandler(tmpl macro.Template) (needsMacroHandler bool) {
// check if we have params like: {name:string} or {name} or {anything:path} without else keyword or any functions used inside these params. // check if we have params like: {name:string} or {name} or {anything:path} without else keyword or any functions used inside these params.
// 1. if we don't have, then we don't need to add a handler before the main route's handler (as I said, no performance if macro is not really used) // 1. if we don't have, then we don't need to add a handler before the main route's handler (as I said, no performance if macro is not really used)
// 2. if we don't have any named params then we don't need a handler too. // 2. if we don't have any named params then we don't need a handler too.
for _, p := range tmpl.Params { for i := range tmpl.Params {
p := tmpl.Params[i]
if p.CanEval() { if p.CanEval() {
// if at least one needs it, then create the handler. // if at least one needs it, then create the handler.
needsMacroHandler = true needsMacroHandler = true
@@ -85,7 +86,8 @@ func MakeFilter(tmpl macro.Template) context.Filter {
} }
return func(ctx *context.Context) bool { return func(ctx *context.Context) bool {
for _, p := range tmpl.Params { for i := range tmpl.Params {
p := tmpl.Params[i]
if !p.CanEval() { if !p.CanEval() {
continue // allow. continue // allow.
} }