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

move sessions and websocket examples, gofmt, fix misspells and experimental optimizations 🍐

Former-commit-id: cae4f94bbd404d26ab13dade02b52f81feaddf24
This commit is contained in:
hiveminded
2017-07-22 22:57:20 +03:00
parent 90b8c1af44
commit 9a0b18acbf
36 changed files with 155 additions and 97 deletions

View File

@@ -0,0 +1,43 @@
package main
import (
"github.com/kataras/iris"
"github.com/kataras/iris/context"
"github.com/kataras/iris/sessions"
)
func main() {
app := iris.New()
sess := sessions.New(sessions.Config{Cookie: "myappsessionid"})
app.Get("/set", func(ctx context.Context) {
s := sess.Start(ctx)
s.SetFlash("name", "iris")
ctx.Writef("Message setted, is available for the next request")
})
app.Get("/get", func(ctx context.Context) {
s := sess.Start(ctx)
name := s.GetFlashString("name")
if name == "" {
ctx.Writef("Empty name!!")
return
}
ctx.Writef("Hello %s", name)
})
app.Get("/test", func(ctx context.Context) {
s := sess.Start(ctx)
name := s.GetFlashString("name")
if name == "" {
ctx.Writef("Empty name!!")
return
}
ctx.Writef("Ok you are coming from /set ,the value of the name is %s", name)
ctx.Writef(", and again from the same context: %s", name)
})
app.Run(iris.Addr(":8080"))
}