mirror of
https://github.com/kataras/iris.git
synced 2025-12-17 18:07:01 +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:
@@ -4,7 +4,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/context"
|
||||
|
||||
"github.com/kataras/iris/sessions"
|
||||
"github.com/kataras/iris/sessions/sessiondb/boltdb"
|
||||
@@ -33,10 +32,10 @@ func main() {
|
||||
// the rest of the code stays the same.
|
||||
app := iris.New()
|
||||
|
||||
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) {
|
||||
s := sess.Start(ctx)
|
||||
//set session values
|
||||
s.Set("name", "iris")
|
||||
@@ -45,7 +44,7 @@ func main() {
|
||||
ctx.Writef("All ok session setted to: %s", s.GetString("name"))
|
||||
})
|
||||
|
||||
app.Get("/set/{key}/{value}", func(ctx context.Context) {
|
||||
app.Get("/set/{key}/{value}", func(ctx iris.Context) {
|
||||
key, value := ctx.Params().Get("key"), ctx.Params().Get("value")
|
||||
s := sess.Start(ctx)
|
||||
// set session values
|
||||
@@ -55,36 +54,36 @@ func main() {
|
||||
ctx.Writef("All ok session setted to: %s", s.GetString(key))
|
||||
})
|
||||
|
||||
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
|
||||
name := sess.Start(ctx).GetString("name")
|
||||
|
||||
ctx.Writef("The name on the /set was: %s", name)
|
||||
})
|
||||
|
||||
app.Get("/get/{key}", func(ctx context.Context) {
|
||||
app.Get("/get/{key}", func(ctx iris.Context) {
|
||||
// get a specific key, as string, if no found returns just an empty string
|
||||
name := sess.Start(ctx).GetString(ctx.Params().Get("key"))
|
||||
|
||||
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
|
||||
sess.Start(ctx).Delete("name")
|
||||
})
|
||||
|
||||
app.Get("/clear", func(ctx context.Context) {
|
||||
app.Get("/clear", func(ctx iris.Context) {
|
||||
// removes all entries
|
||||
sess.Start(ctx).Clear()
|
||||
})
|
||||
|
||||
app.Get("/destroy", func(ctx context.Context) {
|
||||
app.Get("/destroy", func(ctx iris.Context) {
|
||||
//destroy, removes the entire session data and cookie
|
||||
sess.Destroy(ctx)
|
||||
})
|
||||
|
||||
app.Get("/update", func(ctx context.Context) {
|
||||
app.Get("/update", func(ctx iris.Context) {
|
||||
// updates expire date with a new date
|
||||
sess.ShiftExpiration(ctx)
|
||||
})
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/context"
|
||||
|
||||
"github.com/kataras/iris/sessions"
|
||||
"github.com/kataras/iris/sessions/sessiondb/file"
|
||||
@@ -29,10 +28,10 @@ func main() {
|
||||
// the rest of the code stays the same.
|
||||
app := iris.New()
|
||||
|
||||
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) {
|
||||
s := sess.Start(ctx)
|
||||
//set session values
|
||||
s.Set("name", "iris")
|
||||
@@ -41,7 +40,7 @@ func main() {
|
||||
ctx.Writef("All ok session setted to: %s", s.GetString("name"))
|
||||
})
|
||||
|
||||
app.Get("/set/{key}/{value}", func(ctx context.Context) {
|
||||
app.Get("/set/{key}/{value}", func(ctx iris.Context) {
|
||||
key, value := ctx.Params().Get("key"), ctx.Params().Get("value")
|
||||
s := sess.Start(ctx)
|
||||
// set session values
|
||||
@@ -51,36 +50,36 @@ func main() {
|
||||
ctx.Writef("All ok session setted to: %s", s.GetString(key))
|
||||
})
|
||||
|
||||
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
|
||||
name := sess.Start(ctx).GetString("name")
|
||||
|
||||
ctx.Writef("The name on the /set was: %s", name)
|
||||
})
|
||||
|
||||
app.Get("/get/{key}", func(ctx context.Context) {
|
||||
app.Get("/get/{key}", func(ctx iris.Context) {
|
||||
// get a specific key, as string, if no found returns just an empty string
|
||||
name := sess.Start(ctx).GetString(ctx.Params().Get("key"))
|
||||
|
||||
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
|
||||
sess.Start(ctx).Delete("name")
|
||||
})
|
||||
|
||||
app.Get("/clear", func(ctx context.Context) {
|
||||
app.Get("/clear", func(ctx iris.Context) {
|
||||
// removes all entries
|
||||
sess.Start(ctx).Clear()
|
||||
})
|
||||
|
||||
app.Get("/destroy", func(ctx context.Context) {
|
||||
app.Get("/destroy", func(ctx iris.Context) {
|
||||
//destroy, removes the entire session data and cookie
|
||||
sess.Destroy(ctx)
|
||||
})
|
||||
|
||||
app.Get("/update", func(ctx context.Context) {
|
||||
app.Get("/update", func(ctx iris.Context) {
|
||||
// updates expire date with a new date
|
||||
sess.ShiftExpiration(ctx)
|
||||
})
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/context"
|
||||
|
||||
"github.com/kataras/iris/sessions"
|
||||
"github.com/kataras/iris/sessions/sessiondb/leveldb"
|
||||
@@ -34,10 +33,10 @@ func main() {
|
||||
// the rest of the code stays the same.
|
||||
app := iris.New()
|
||||
|
||||
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) {
|
||||
s := sess.Start(ctx)
|
||||
//set session values
|
||||
s.Set("name", "iris")
|
||||
@@ -46,7 +45,7 @@ func main() {
|
||||
ctx.Writef("All ok session setted to: %s", s.GetString("name"))
|
||||
})
|
||||
|
||||
app.Get("/set/{key}/{value}", func(ctx context.Context) {
|
||||
app.Get("/set/{key}/{value}", func(ctx iris.Context) {
|
||||
key, value := ctx.Params().Get("key"), ctx.Params().Get("value")
|
||||
s := sess.Start(ctx)
|
||||
// set session values
|
||||
@@ -56,36 +55,36 @@ func main() {
|
||||
ctx.Writef("All ok session setted to: %s", s.GetString(key))
|
||||
})
|
||||
|
||||
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
|
||||
name := sess.Start(ctx).GetString("name")
|
||||
|
||||
ctx.Writef("The name on the /set was: %s", name)
|
||||
})
|
||||
|
||||
app.Get("/get/{key}", func(ctx context.Context) {
|
||||
app.Get("/get/{key}", func(ctx iris.Context) {
|
||||
// get a specific key, as string, if no found returns just an empty string
|
||||
name := sess.Start(ctx).GetString(ctx.Params().Get("key"))
|
||||
|
||||
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
|
||||
sess.Start(ctx).Delete("name")
|
||||
})
|
||||
|
||||
app.Get("/clear", func(ctx context.Context) {
|
||||
app.Get("/clear", func(ctx iris.Context) {
|
||||
// removes all entries
|
||||
sess.Start(ctx).Clear()
|
||||
})
|
||||
|
||||
app.Get("/destroy", func(ctx context.Context) {
|
||||
app.Get("/destroy", func(ctx iris.Context) {
|
||||
//destroy, removes the entire session data and cookie
|
||||
sess.Destroy(ctx)
|
||||
})
|
||||
|
||||
app.Get("/update", func(ctx context.Context) {
|
||||
app.Get("/update", func(ctx iris.Context) {
|
||||
// updates expire date with a new date
|
||||
sess.ShiftExpiration(ctx)
|
||||
})
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/context"
|
||||
|
||||
"github.com/kataras/iris/sessions"
|
||||
"github.com/kataras/iris/sessions/sessiondb/redis"
|
||||
@@ -40,10 +39,10 @@ func main() {
|
||||
// the rest of the code stays the same.
|
||||
app := iris.New()
|
||||
|
||||
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) {
|
||||
s := sess.Start(ctx)
|
||||
//set session values
|
||||
s.Set("name", "iris")
|
||||
@@ -52,29 +51,29 @@ func main() {
|
||||
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
|
||||
name := sess.Start(ctx).GetString("name")
|
||||
|
||||
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
|
||||
sess.Start(ctx).Delete("name")
|
||||
})
|
||||
|
||||
app.Get("/clear", func(ctx context.Context) {
|
||||
app.Get("/clear", func(ctx iris.Context) {
|
||||
// removes all entries
|
||||
sess.Start(ctx).Clear()
|
||||
})
|
||||
|
||||
app.Get("/destroy", func(ctx context.Context) {
|
||||
app.Get("/destroy", func(ctx iris.Context) {
|
||||
//destroy, removes the entire session data and cookie
|
||||
sess.Destroy(ctx)
|
||||
})
|
||||
|
||||
app.Get("/update", func(ctx context.Context) {
|
||||
app.Get("/update", func(ctx iris.Context) {
|
||||
// updates expire date with a new date
|
||||
sess.ShiftExpiration(ctx)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user