mirror of
https://github.com/kataras/iris.git
synced 2025-01-25 03:31:04 +01:00
126c4de29b
1. Fix index, including both start and end. So Literal[start:end+1] will be a valid part. 2. Replace any with string, add file param type 3. Start of making the evaluator, starting with regexp for param types (these expression can be changed or/and overriden by user later on) Former-commit-id: ab95265f953dadbf84170b543e1ff8840f9c4a14
45 lines
800 B
Go
45 lines
800 B
Go
package ast
|
|
|
|
type ParamType uint8
|
|
|
|
const (
|
|
ParamTypeUnExpected ParamType = iota
|
|
// /myparam1
|
|
ParamTypeString
|
|
// /42
|
|
ParamTypeInt
|
|
// /myparam
|
|
ParamTypeAlphabetical
|
|
// /main.css
|
|
ParamTypeFile
|
|
// /myparam1/myparam2
|
|
ParamTypePath
|
|
)
|
|
|
|
var paramTypes = map[string]ParamType{
|
|
"string": ParamTypeString,
|
|
"int": ParamTypeInt,
|
|
"alphabetical": ParamTypeAlphabetical,
|
|
"file": ParamTypeFile,
|
|
"path": ParamTypePath,
|
|
// could be named also:
|
|
// "tail":
|
|
// "wild"
|
|
// "wildcard"
|
|
|
|
}
|
|
|
|
func LookupParamType(ident string) ParamType {
|
|
if typ, ok := paramTypes[ident]; ok {
|
|
return typ
|
|
}
|
|
return ParamTypeUnExpected
|
|
}
|
|
|
|
type ParamStatement struct {
|
|
Name string // id
|
|
Type ParamType // int
|
|
Funcs []ParamFunc // range
|
|
ErrorCode int // 404
|
|
}
|