Hi, I'm developing a REST CodeIgniter Controller and need to POST and PUT to a URL in multiple formats.
The main formats I can think of would be:
- XML
- JSON
- HTML Form data
There will be a response format defined in the URI e.g. /format/xml or /format/csv. I don't want to have to define the request format in the URI as well.
I was wondering if anyone has any suggestions on finding out the request format so my script can complete the request.
I'm thinking it may be possible to get this data from the request headers "content-type"?
- "content-type: text/xml" = XML
- "content-type: application/json" = JSON
- "content-type: text/plain" = HTLM Form data *i think!
Would this method be robust or are there better approaches out there?
Thanks.