1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-20 11:27:06 +00:00

made it work but looking for another approach

Former-commit-id: e61c4573543c57b8d6d4ef2583e40f52c391402f
This commit is contained in:
kataras
2017-12-04 05:06:03 +02:00
parent dd5de52f34
commit 7043f352d9
20 changed files with 855 additions and 792 deletions

View File

@@ -51,21 +51,14 @@ const (
ParamTypePath
)
// ValidKind will return true if at least one param type is supported
// for this std kind.
func ValidKind(k reflect.Kind) bool {
switch k {
case reflect.String:
fallthrough
case reflect.Int:
fallthrough
case reflect.Int64:
fallthrough
case reflect.Bool:
return true
default:
return false
func (pt ParamType) String() string {
for k, v := range paramTypes {
if v == pt {
return k
}
}
return "unexpected"
}
// Not because for a single reason
@@ -96,6 +89,23 @@ func (pt ParamType) Kind() reflect.Kind {
return reflect.Invalid // 0
}
// ValidKind will return true if at least one param type is supported
// for this std kind.
func ValidKind(k reflect.Kind) bool {
switch k {
case reflect.String:
fallthrough
case reflect.Int:
fallthrough
case reflect.Int64:
fallthrough
case reflect.Bool:
return true
default:
return false
}
}
// Assignable returns true if the "k" standard type
// is assignabled to this ParamType.
func (pt ParamType) Assignable(k reflect.Kind) bool {
@@ -133,6 +143,30 @@ func LookupParamType(ident string) ParamType {
return ParamTypeUnExpected
}
// LookupParamTypeFromStd accepts the string representation of a standard go type.
// It returns a ParamType, but it may differs for example
// the alphabetical, file, path and string are all string go types, so
// make sure that caller resolves these types before this call.
//
// string matches to string
// int matches to int
// int64 matches to long
// bool matches to boolean
func LookupParamTypeFromStd(goType string) ParamType {
switch goType {
case "string":
return ParamTypeString
case "int":
return ParamTypeInt
case "int64":
return ParamTypeLong
case "bool":
return ParamTypeBoolean
default:
return ParamTypeUnExpected
}
}
// ParamStatement is a struct
// which holds all the necessary information about a macro parameter.
// It holds its type (string, int, alphabetical, file, path),