1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-19 02:47:04 +00:00

8.4.0 | New MVC Features | Refactor examples and godoc for go 1.9 use. Read HISTORY.md.

Former-commit-id: 90c05e743052bc3722e7fefaa0cbb0ed5153a1fb
This commit is contained in:
kataras
2017-08-27 20:35:23 +03:00
parent a2de506f80
commit 42b123975c
100 changed files with 405 additions and 981 deletions

View File

@@ -7,7 +7,6 @@ package main
import (
"github.com/kataras/iris"
"github.com/kataras/iris/context"
"github.com/kataras/iris/sessions"
@@ -30,10 +29,10 @@ func newApp() *iris.Application {
Decode: secureCookie.Decode,
})
app.Get("/", func(ctx context.Context) {
app.Get("/", func(ctx iris.Context) {
ctx.Writef("You should navigate to the /set, /get, /delete, /clear,/destroy instead")
})
app.Get("/set", func(ctx context.Context) {
app.Get("/set", func(ctx iris.Context) {
//set session values
s := mySessions.Start(ctx)
@@ -43,7 +42,7 @@ func newApp() *iris.Application {
ctx.Writef("All ok session setted to: %s", s.GetString("name"))
})
app.Get("/get", func(ctx context.Context) {
app.Get("/get", func(ctx iris.Context) {
// get a specific key, as string, if no found returns just an empty string
s := mySessions.Start(ctx)
name := s.GetString("name")
@@ -51,23 +50,23 @@ func newApp() *iris.Application {
ctx.Writef("The name on the /set was: %s", name)
})
app.Get("/delete", func(ctx context.Context) {
app.Get("/delete", func(ctx iris.Context) {
// delete a specific key
s := mySessions.Start(ctx)
s.Delete("name")
})
app.Get("/clear", func(ctx context.Context) {
app.Get("/clear", func(ctx iris.Context) {
// removes all entries
mySessions.Start(ctx).Clear()
})
app.Get("/update", func(ctx context.Context) {
app.Get("/update", func(ctx iris.Context) {
// updates expire date with a new date
mySessions.ShiftExpiration(ctx)
})
app.Get("/destroy", func(ctx context.Context) {
app.Get("/destroy", func(ctx iris.Context) {
//destroy, removes the entire session data and cookie
mySessions.Destroy(ctx)
})