Skip to content

Instantly share code, notes, and snippets.

@jrasanen
Last active June 25, 2016 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrasanen/d9ae3caa71c45c2bbe927d3032a1b4ee to your computer and use it in GitHub Desktop.
Save jrasanen/d9ae3caa71c45c2bbe927d3032a1b4ee to your computer and use it in GitHub Desktop.
(dlv) print request
*struct net/http.Request {
Method: "POST",
URL: *struct net/url.URL {
Scheme: "",
Opaque: "",
User: *struct net/url.Userinfo nil,
Host: "",
Path: "/counts",
RawPath: "",
RawQuery: "",
Fragment: "",
},
Proto: "HTTP/1.1",
ProtoMajor: 1,
ProtoMinor: 1,
Header: net/http.Header [],
Body: io.ReadCloser(*struct io/ioutil.nopCloser) *{
io.Reader: io.Reader(*struct strings.Reader) *(*struct strings.Reader)(0xc8200cc2e0),
},
ContentLength: 12,
TransferEncoding: []string len: 0, cap: 0, [],
Close: false,
Host: "",
Form: net/url.Values [],
PostForm: net/url.Values [],
MultipartForm: *mime/multipart.Form nil,
Trailer: net/http.Header [],
RemoteAddr: "",
RequestURI: "",
TLS: *struct crypto/tls.ConnectionState nil,
Cancel: <-chan struct {} {},
}
func TestCountsValidPath(t *testing.T) {
data := url.Values{}
data.Set("path", "/root")
request, err := http.NewRequest("POST", "/counts", strings.NewReader(data.Encode()))
if err != nil {
t.Fatal(err)
}
recorder := httptest.NewRecorder()
handler := http.HandlerFunc(counts)
handler.ServeHTTP(recorder, request)
if status := recorder.Code; status != http.StatusOK {
t.Errorf("handler returned wrong status code: got %v want %v",
status, http.StatusOK)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment