1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-22 20:37:05 +00:00
Former-commit-id: 9e5f0a08049b83605aa847b8f51fb856427354a6
This commit is contained in:
hiveminded
2017-09-07 16:20:31 +03:00
parent fcfc65a7bc
commit 8a9a498316
15 changed files with 184 additions and 25 deletions

View File

@@ -18,13 +18,18 @@ const (
// Declaration: /mypath/{myparam:string} or /mypath{myparam}
ParamTypeString
// ParamTypeInt is the integer, a number type.
// Allows only numbers (0-9)
// Allows only possitive numbers (0-9)
// Declaration: /mypath/{myparam:int}
ParamTypeInt
// ParamTypeLong is the integer, a number type.
// Allows only numbers (0-9)
// Allows only possitive numbers (0-9)
// Declaration: /mypath/{myparam:long}
ParamTypeLong
// ParamTypeBoolean is the bool type.
// Allows only "1" or "t" or "T" or "TRUE" or "true" or "True"
// or "0" or "f" or "F" or "FALSE" or "false" or "False".
// Declaration: /mypath/{myparam:boolean}
ParamTypeBoolean
// ParamTypeAlphabetical is the alphabetical/letter type type.
// Allows letters only (upper or lowercase)
// Declaration: /mypath/{myparam:alphabetical}
@@ -49,6 +54,7 @@ var paramTypes = map[string]ParamType{
"string": ParamTypeString,
"int": ParamTypeInt,
"long": ParamTypeLong,
"boolean": ParamTypeBoolean,
"alphabetical": ParamTypeAlphabetical,
"file": ParamTypeFile,
"path": ParamTypePath,

View File

@@ -131,6 +131,13 @@ func TestParseParam(t *testing.T) {
Type: ast.ParamTypeLong,
ErrorCode: 404,
}}, // 8
{true,
ast.ParamStatement{
Src: "{has:boolean else 404}",
Name: "has",
Type: ast.ParamTypeBoolean,
ErrorCode: 404,
}}, // 9
}