-
Notifications
You must be signed in to change notification settings - Fork 372
Closed
Description
The new http.Request.Context() in Go 1.7 creates a shallow copy of the original request that requires the caller to save it upstream. This copy has a different address and therefore has a different map key in the context map provided by gorilla/context.
In order to fix this in gorilla/sessions we need to make a breaking change for Go 1.7+ users:
- Use build tags to provide two context implementations as per gorilla/csrf: https://github.com/gorilla/csrf/blob/master/context_legacy.go
- The only use of
context.Setis withinGetRegistry- this will now need to return(*Registry, *http.Request).
- func GetRegistry(r *http.Request) *Registry {
+ func GetRegistry(r *http.Request) (*Registry, *http.Request)- There is a reasonable amount of code in the wild that this will break: https://github.com/search?q=%22sessions.GetRegistry%22+language%3Ago&type=Code&utf8=%E2%9C%93 as many users are calling
sessions.GetRegistry(r).Get(store, name). They will need to change their code:
- sessions.GetRegistry(r).Get(s, name)
+ var reg *sessions.Registry
+ reg, r = sessions.GetRegistry(r)
+ sess, err := reg.Get(store, name)That should be about it. This is unavoidable unfortunately, but is (thankfully) a compile-time breaking change that we can document clearly.
Ref: gorilla/mux#168
Reactions are currently unavailable