1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-23 12:57:05 +00:00

Update to 8.4.0 | New macro type, new high-optimized MVC features. Read HISTORY.md

Former-commit-id: b72a23ba063be60a9750c8b1b0df024b0c8ed549
This commit is contained in:
kataras
2017-08-27 18:46:04 +03:00
parent 8602517371
commit 591806795e
37 changed files with 1242 additions and 453 deletions

View File

@@ -208,7 +208,7 @@ func (m *Macro) getFunc(funcName string) ParamEvaluatorBuilder {
// Map contains the default macros mapped to their types.
// This is the manager which is used by the caller to register custom
// parameter functions per param-type (String, Int, Alphabetical, File, Path).
// parameter functions per param-type (String, Int, Long, Alphabetical, File, Path).
type Map struct {
// string type
// anything
@@ -216,6 +216,9 @@ type Map struct {
// int type
// only numbers (0-9)
Int *Macro
// long an int64 type
// only numbers (0-9)
Long *Macro
// alphabetical/letter type
// letters only (upper or lowercase)
Alphabetical *Macro
@@ -241,6 +244,7 @@ func NewMap() *Map {
// it allows everything, so no need for a regexp here.
String: newMacro(func(string) bool { return true }),
Int: newMacro(MustNewEvaluatorFromRegexp("^[0-9]+$")),
Long: newMacro(MustNewEvaluatorFromRegexp("^[0-9]+$")),
Alphabetical: newMacro(MustNewEvaluatorFromRegexp("^[a-zA-Z ]+$")),
File: newMacro(MustNewEvaluatorFromRegexp("^[a-zA-Z0-9_.-]*$")),
// it allows everything, we have String and Path as different
@@ -259,6 +263,8 @@ func (m *Map) Lookup(typ ast.ParamType) *Macro {
switch typ {
case ast.ParamTypeInt:
return m.Int
case ast.ParamTypeLong:
return m.Long
case ast.ParamTypeAlphabetical:
return m.Alphabetical
case ast.ParamTypeFile: