I am working in a Golang project, I need to perform some operations over an external API: GET, PUT, POST and DELETE. Currently am using net/http
I created a &http.Client{}
to make GET and PUT, that is working as expected.
Now I need to perform a DELETE and I cannot find anything about it, is it supported? I need to call basically an url like this:
somedomain.com/theresource/:id
Method: DELETE
How can I perform that?
PUT
request? How making aPUT
request would be different from making aDELETE
one? – zerkms Sep 19 '17 at 21:44DELETE
requests you might need to configure CORS (developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS). What CORS does is basically send anOPTIONS
request that asks for permission to send aDELETE
request. That would happen if you are sending requests from the browser. You can try tools likecurl
orpostman
to make sure that an actualDELETE
request is being sent. Also, if it turns out to be the problem, you can use a Go framework like Gorilla to properly handle CORS. – Michał Sep 19 '17 at 22:36