iris icon indicating copy to clipboard operation
iris copied to clipboard

[Help]Attach session to Context

Open sunstrikemd opened this issue 9 years ago • 1 comments

Below is my code:

type newContext struct { context.Context Session *sessions.Sessions }

session := sessions.New(sessions.Config{ Cookie: Cookie, })

app.ContextPool.Attach(func() context.Context { return &newContext{ Session: session, Context: context.NewContext(app), } })

app.UseGlobal(func(ctx context.Context) { ctx.Session // <- for example here not working right now ;( ctx.Next() })

I have looking through example and overridden Context struct to attach my own context, my question is how can i access session in context something like ctx.Session, or what i'm doing wrong? can someone help me?

sunstrikemd avatar Jul 24 '17 08:07 sunstrikemd

duplicate of #667

@sunstrikemd we have an example too: https://github.com/kataras/iris/tree/master/_examples/routing/custom-context/new-implementation

hiveminded avatar Jul 24 '17 11:07 hiveminded