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

fix https://github.com/kataras/iris/issues/1020, redis database stores the int as float64, so make that type assertion on GetInt as well

Former-commit-id: d29abdfe3a39fa1e046acbc5d118421a153d9c04
This commit is contained in:
Gerasimos Maropoulos
2018-06-03 02:47:48 +03:00
parent b4856d542d
commit f83e125d7f
2 changed files with 38 additions and 0 deletions

View File

@@ -66,6 +66,24 @@ func main() {
ctx.Writef("All ok session value of the '%s' is: %s", key, s.GetString(key))
})
app.Get("/set/int/{key}/{value}", func(ctx iris.Context) {
key := ctx.Params().Get("key")
value, _ := ctx.Params().GetInt("value")
s := sess.Start(ctx)
// set session values
s.Set(key, value)
valueSet := s.Get(key)
// test if setted here
ctx.Writef("All ok session value of the '%s' is: %v", key, valueSet)
})
app.Get("/get/{key}", func(ctx iris.Context) {
key := ctx.Params().Get("key")
value := sess.Start(ctx).Get(key)
ctx.Writef("The '%s' on the /set was: %v", key, value)
})
app.Get("/get", func(ctx iris.Context) {
// get a specific key, as string, if no found returns just an empty string
name := sess.Start(ctx).GetString("name")