-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mux.Vars breaks with Go 1.7 #168
Comments
Thanks for reporting this—it does makes sense. The new We can do this without breaking the public API as the only uses of Lines 346 to 356 in bd09be0
router.ServeHTTP so we can safely modify these to return the copied *http.Request .
You're welcome to submit a PR (with tests) and/or I'll have something done by early next week. You can pretty much lift the build-tag based implementation out of gorilla/csrf: https://github.com/gorilla/csrf/blob/master/context_legacy.go PS: My bigger problem is gorilla/sessions which does require breaking the API to fix it as a couple of public functions will need to return a |
Go 1.7 adds native support for context.Context by adding Context and WithContext methods to http.Request.
The expectation is that, if you want to add anything to the context of the request, you use http.Request.WithContext, which returns a shallow copy of the request that you would pass down. Unfortunately, this seems break the way gorilla mux stores vars.
Here's a simple Go program that demonstrates the problem:
Once Go 1.7 is out, basically anything that uses middleware to set context values, cancellations or deadlines is going to break mux.
It would be ideal of the vars were actually stored in the context.Context, which may be possible without breaking the API?
The text was updated successfully, but these errors were encountered: