2017-03-27 03:09:44 +02:00
|
|
|
package ast
|
|
|
|
|
|
|
|
type ParamType uint8
|
|
|
|
|
|
|
|
const (
|
|
|
|
ParamTypeUnExpected ParamType = iota
|
|
|
|
// /myparam1
|
|
|
|
ParamTypeString
|
2017-03-27 21:33:19 +02:00
|
|
|
// /42
|
|
|
|
ParamTypeInt
|
2017-03-27 03:09:44 +02:00
|
|
|
// /myparam
|
|
|
|
ParamTypeAlphabetical
|
2017-03-27 21:33:19 +02:00
|
|
|
// /main.css
|
|
|
|
ParamTypeFile
|
2017-03-27 03:09:44 +02:00
|
|
|
// /myparam1/myparam2
|
2017-03-27 13:38:10 +02:00
|
|
|
ParamTypePath
|
2017-03-27 03:09:44 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
var paramTypes = map[string]ParamType{
|
|
|
|
"string": ParamTypeString,
|
2017-03-27 21:33:19 +02:00
|
|
|
"int": ParamTypeInt,
|
2017-03-27 03:09:44 +02:00
|
|
|
"alphabetical": ParamTypeAlphabetical,
|
2017-03-27 21:33:19 +02:00
|
|
|
"file": ParamTypeFile,
|
2017-03-27 13:38:10 +02:00
|
|
|
"path": ParamTypePath,
|
2017-03-27 03:09:44 +02:00
|
|
|
// could be named also:
|
|
|
|
// "tail":
|
|
|
|
// "wild"
|
|
|
|
// "wildcard"
|
2017-03-27 21:33:19 +02:00
|
|
|
|
2017-03-27 03:09:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|