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

publish v12.2.0-alpha6

This commit is contained in:
Gerasimos (Makis) Maropoulos
2022-02-18 22:19:33 +02:00
parent 4899fe95f4
commit 41026c9209
21 changed files with 984 additions and 284 deletions

View File

@@ -16,7 +16,7 @@ type BusinessModel struct {
// NewApp returns a new application for showcasing the sessions feature.
func NewApp(sess *sessions.Sessions) *iris.Application {
app := iris.New()
app.Use(sess.Handler()) // session is always non-nil inside handlers now.
app.Use(sess.Handler()) // register the session manager on a group of routes or the root app.
app.Get("/", func(ctx iris.Context) {
session := sessions.Get(ctx) // same as sess.Start(ctx, cookieOptions...)

View File

@@ -15,23 +15,21 @@ import (
)
func newApp() *iris.Application {
app := iris.New()
cookieName := "_session_id"
// AES only supports key sizes of 16, 24 or 32 bytes.
// You either need to provide exactly that amount or you derive the key from what you type in.
hashKey := securecookie.GenerateRandomKey(64)
blockKey := securecookie.GenerateRandomKey(32)
s := securecookie.New(hashKey, blockKey)
mySessions := sessions.New(sessions.Config{
Cookie: cookieName,
Encoding: s,
AllowReclaim: true,
})
app = example.NewApp(mySessions)
return app
// mySessions.UseDatabase(...see sessions/database example folder)
return example.NewApp(mySessions)
}
func main() {