Skip to content

Commit b43fe46

Browse files
kostya-shbradfitz
authored andcommitted
net/http/httptest: show usage of httptest.NewRequest in example
Change ExampleResponseRecorder to use httptest.NewRequest instead of http.NewRequest. This makes the example shorter and shows how to use one more function from the httptest package. Change-Id: I3d35869bd0a4daf1c7551b649428bb2f2a45eba2 Reviewed-on: https://go-review.googlesource.com/24480 Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 3e9d6e0 commit b43fe46

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/net/http/httptest/example_test.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ func ExampleResponseRecorder() {
1717
http.Error(w, "something failed", http.StatusInternalServerError)
1818
}
1919

20-
req, err := http.NewRequest("GET", "http://example.com/foo", nil)
21-
if err != nil {
22-
log.Fatal(err)
23-
}
24-
20+
req := httptest.NewRequest("GET", "http://example.com/foo", nil)
2521
w := httptest.NewRecorder()
2622
handler(w, req)
2723

0 commit comments

Comments
 (0)