major refactoring
This commit is contained in:
parent
826d035d3e
commit
f2d57c6e18
4 changed files with 87 additions and 89 deletions
28
claims.go
28
claims.go
|
|
@ -29,17 +29,37 @@ func (c Claims) GetBool(key string) (b bool) {
|
|||
|
||||
// GetInt returns an int from the claims map
|
||||
func (c Claims) GetInt(key string) (i int) {
|
||||
if f, ok := c.getFloat64(key); ok {
|
||||
return int(f)
|
||||
}
|
||||
if v, ok := c.Get(key); ok && v != nil {
|
||||
i, _ = v.(int)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetFloat returns a float from the claims map
|
||||
func (c Claims) GetFloat(key string) (f float64) {
|
||||
if v, ok := c.Get(key); ok && v != nil {
|
||||
f, _ = v.(float64)
|
||||
// GetInt64 returns an int64 from the claims map
|
||||
func (c Claims) GetInt64(key string) (i int64) {
|
||||
if f, ok := c.getFloat64(key); ok {
|
||||
return int64(f)
|
||||
}
|
||||
if v, ok := c.Get(key); ok && v != nil {
|
||||
i, _ = v.(int64)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// getFloat64 returns a float64 and ok from the claims map
|
||||
func (c Claims) getFloat64(key string) (f float64, fok bool) {
|
||||
if v, ok := c.Get(key); ok && v != nil {
|
||||
f, fok = v.(float64)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetFloat64 returns a float64 from the claims map
|
||||
func (c Claims) GetFloat64(key string) (f float64) {
|
||||
f, _ = c.getFloat64(key)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue