You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
provide workaround to save everyone that is using an external library that stored the http.Request as a map key.
eg. nosurf, gorilla context ..........
boy once people start using the built in context object on the http.Request they are going to find some fun quirks, because of the way context is tied to the http.Request
the http.Request changes and therefore libraries like nosurf store the http.Request in a map key, but as soon you store a value the http.Request changes and then the http.Request
cannot be found in the map anymore....
I can just imagine the number of applications that could break because of this.... anyway the temporary workaround will save you, but if you're using
a non `lars.Context` handler be sure to shallow copy the request to avoid this issue.
```go
// because 'r' is a copy of a pointer to allow the information to get
// back to the caller, need to set the value of 'r' as below with '*r'
func(w http.ResponseWriter, r *http.Request) {
*r = *r.WithContext(context.WithValue(r.Context(), 0, "testval1"))
}
```
0 commit comments