]> Cypherpunks repositories - gostls13.git/commitdiff
net/http/httptest: show usage of httptest.NewRequest in example
authorKonstantin Shaposhnikov <k.shaposhnikov@gmail.com>
Sat, 25 Jun 2016 12:32:40 +0000 (20:32 +0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 27 Jun 2016 21:08:47 +0000 (21:08 +0000)
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 <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/net/http/httptest/example_test.go

index 42a0ec953b27e22c329a6cd55a4dd14a3b188182..124ce7513efc871ecfbf4120801c6b1daecd46ac 100644 (file)
@@ -17,11 +17,7 @@ func ExampleResponseRecorder() {
                http.Error(w, "something failed", http.StatusInternalServerError)
        }
 
-       req, err := http.NewRequest("GET", "http://example.com/foo", nil)
-       if err != nil {
-               log.Fatal(err)
-       }
-
+       req := httptest.NewRequest("GET", "http://example.com/foo", nil)
        w := httptest.NewRecorder()
        handler(w, req)