I'm trying out go-restful. I found an example here: go example
I try to use curl to post data:
curl -H "Content-Type: text/xml" -X POST -d "<Product><Id>1</Id><Title>The First</Title></Product>" localhost:8080/products
but it didn't work. My questions are:
how to use curl to post data in this example ?
how can this program read xml data into a struct using ?
err := req.ReadEntity(updatedProduct)
(In other examples, req.ReadEntity is able to read json data. How can this single function read data into different structs?)
thanks:)
This library doesnt recognize text/xml
header for some reason, you should use application/xml
const (
MIME_XML = "application/xml"
.....
Here is the difference rfc3023:
If an XML document -- that is, the unprocessed, source XML document -- is readable by casual users, text/xml is preferable to application/xml. MIME user agents (and web user agents) that do not have explicit support for text/xml will treat it as text/plain, for example, by displaying the XML MIME entity as plain text. Application/xml is preferable when the XML MIME entity is unreadable by casual users.