HTTP Delete

4,837 views
Skip to first unread message

Joseph Mikhail

unread,
Dec 1, 2011, 3:51:59 AM12/1/11
to golang-nuts
I see that in the Go package of HTTP,http://golang.org/pkg/http/,
there is Do, Get, Head, Post & PostForm but where is Delete? How does
one do a HTTP Delete request?

Andrew Gerrand

unread,
Dec 1, 2011, 5:23:11 AM12/1/11
to golan...@googlegroups.com
You construct an *http.Request and pass it to the http.DefaultClient.Do:

req, err := http.NewRequest("DELETE", url, nil)
// handle err
resp, err := http.DefaultClient.Do(req)
// handle err
// do something with resp


Andrew
Reply all
Reply to author
Forward
0 new messages