alexedwards / scs

HTTP Session Management for Go
MIT License
2.09k stars 166 forks source link

scs: no session data in context in fiber framework #106

Closed Koredeoluwafemi closed 3 years ago

Koredeoluwafemi commented 3 years ago

I am having this issue on the go fiber framework, I want to know how and where do I pass in the http.handler into the LoadAndSave middleware

NWBY commented 3 years ago

Stuck on this one as well. Anyone got any ideas?

cc @alexedwards

alexedwards commented 3 years ago

If you're getting a no session data in context error it means that the request context is not being propagated throughout the middleware -> handler chain correctly.

The scs.LoadAndSave method is standard net/http compatible middleware, so if Fiber isn't propagating the request context from it, then it sounds like either bug in the Fiber codebase or the result of a deliberate design decision by them. I think you'll need to pose this question to the Fiber team to get to the root of the problem.

alexedwards commented 3 years ago

I've updated the compatibility note in the README to warn people that using Fiber with this package may not work correctly: https://github.com/alexedwards/scs#compatibility

As mentioned above, I think the incompatibility exists due to a design decision by the Fiber developers to not propagate request context, rather than there being a bug with SCS. So I'm going to close this issue but if you disagree then please reopen.