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

Update to 8.3.0 | MVC Models and Bindings and fix of #723 , read HISTORY.md

Former-commit-id: d8f66d8d370c583a288333df2a14c6ee2dc56466
This commit is contained in:
kataras
2017-08-18 17:09:18 +03:00
parent 398d1e816c
commit b96476d100
53 changed files with 12642 additions and 1046 deletions

View File

@@ -137,6 +137,11 @@ var errFindParse = errors.New("Unable to find the %s with key: %s. Found? %#v")
// GetInt same as Get but returns as int, if not found then returns -1 and an error.
func (s *Session) GetInt(key string) (int, error) {
return s.GetIntDefault(key, -1)
}
// GetIntDefault same as Get but returns as int, if not found then returns the "defaultValue".
func (s *Session) GetIntDefault(key string, defaultValue int) (int, error) {
v := s.Get(key)
if vint, ok := v.(int); ok {
@@ -147,7 +152,7 @@ func (s *Session) GetInt(key string) (int, error) {
return strconv.Atoi(vstring)
}
return -1, errFindParse.Format("int", key, v)
return defaultValue, errFindParse.Format("int", key, v)
}
// GetInt64 same as Get but returns as int64, if not found then returns -1 and an error.