1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 18:07:01 +00:00
Former-commit-id: 3ac995ea77b4629dc7b0d580b9e36d9e302b96ee
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-05-18 18:43:39 +03:00
parent f3745cebbd
commit 9b172fe4ab
2 changed files with 34 additions and 2 deletions

View File

@@ -77,9 +77,29 @@ func NewApp(sess *sessions.Sessions) *iris.Application {
session := sessions.Get(ctx)
// get a specific key, as string, if no found returns just an empty string
key := ctx.Params().Get("key")
name := session.GetString(key)
value := session.Get(key)
ctx.Writef("The name on the /set was: %s", name)
ctx.Writef("The [%s:%T] on the /set was: %v", key, value, value)
})
app.Get("/set/{type}/{key}/{value}", func(ctx iris.Context) {
session := sessions.Get(ctx)
key := ctx.Params().Get("key")
var value interface{}
switch ctx.Params().Get("type") {
case "int":
value = ctx.Params().GetIntDefault("value", 0)
case "float64":
value = ctx.Params().GetFloat64Default("value", 0.0)
default:
value = ctx.Params().Get("value")
}
session.Set(key, value)
value = session.Get(key)
ctx.Writef("Key: %s, Type: %T, Value: %v", key, value, value)
})
app.Get("/delete", func(ctx iris.Context) {