mirror of
https://github.com/kataras/iris.git
synced 2026-01-10 05:25:58 +00:00
@@ -107,6 +107,7 @@ func MakeFilter(tmpl macro.Template) context.Filter {
|
||||
entry, found := ctx.Params().Store.GetEntryAt(p.Index)
|
||||
if !found {
|
||||
// should never happen.
|
||||
ctx.StatusCode(p.ErrCode) // status code can change from an error handler, set it here.
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ func Parse(fullpath string, paramTypes []ast.ParamType) ([]*ast.ParamStatement,
|
||||
}
|
||||
// if we have param type path but it's not the last path part
|
||||
if ast.IsTrailing(stmt.Type) && i < len(pathParts)-1 {
|
||||
return nil, fmt.Errorf("%s: parameter type \"%s\" should be registered to the very end of a path", s, stmt.Type.Indent())
|
||||
return nil, fmt.Errorf("%s: parameter type \"%s\" should be registered to the very end of a path once", s, stmt.Type.Indent())
|
||||
}
|
||||
|
||||
statements = append(statements, stmt)
|
||||
|
||||
@@ -50,6 +50,31 @@ var (
|
||||
return func(paramValue string) bool {
|
||||
return max >= len(paramValue)
|
||||
}
|
||||
}).
|
||||
// checks if param value's matches the given input
|
||||
RegisterFunc("eq", func(s string) func(string) bool {
|
||||
return func(paramValue string) bool {
|
||||
return paramValue == s
|
||||
}
|
||||
}).
|
||||
// checks if param value's matches at least one of the inputs
|
||||
RegisterFunc("eqor", func(texts []string) func(string) bool {
|
||||
if len(texts) == 1 {
|
||||
text := texts[0]
|
||||
return func(paramValue string) bool {
|
||||
return paramValue == text
|
||||
}
|
||||
}
|
||||
|
||||
return func(paramValue string) bool {
|
||||
for _, s := range texts {
|
||||
if paramValue == s {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
})
|
||||
|
||||
// Int or number type
|
||||
|
||||
Reference in New Issue
Block a user