fix: ineffectual assignments
This commit is contained in:
parent
ad86a3b46b
commit
c048db76e6
|
@ -51,13 +51,11 @@ func TestWith(t *testing.T) {
|
||||||
|
|
||||||
middleware := func(next http.Handler) http.Handler {
|
middleware := func(next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
newr := r
|
|
||||||
|
|
||||||
// first time -> store 1
|
// first time -> store 1
|
||||||
value := r.Context().Value(key)
|
value := r.Context().Value(key)
|
||||||
if value == nil {
|
if value == nil {
|
||||||
newr = r.WithContext(context.WithValue(r.Context(), key, int(1)))
|
r = r.WithContext(context.WithValue(r.Context(), key, int(1)))
|
||||||
next.ServeHTTP(w, newr)
|
next.ServeHTTP(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,8 +65,8 @@ func TestWith(t *testing.T) {
|
||||||
t.Fatalf("value is not an int")
|
t.Fatalf("value is not an int")
|
||||||
}
|
}
|
||||||
cast++
|
cast++
|
||||||
newr = r.WithContext(context.WithValue(r.Context(), key, cast))
|
r = r.WithContext(context.WithValue(r.Context(), key, cast))
|
||||||
next.ServeHTTP(w, newr)
|
next.ServeHTTP(w, r)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue