mirror of
https://github.com/kataras/iris.git
synced 2025-12-19 10:57:05 +00:00
Add notes for the new lead maintainer of the open-source iris project and align with @get-ion/ion by @hiveminded
Former-commit-id: da4f38eb9034daa49446df3ee529423b98f9b331
This commit is contained in:
43
sessions/_examples/flash-messages/main.go
Normal file
43
sessions/_examples/flash-messages/main.go
Normal 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"))
|
||||
}
|
||||
Reference in New Issue
Block a user