I'm using Drupal services with REST server to provide API.
Previously I only work with 1 type of response, JSON, so I didn't need extra extension ".json" to the URL.
Now I have to add new formatter, XML.
Then the problem begin, all API without any extension (.json or .xml) will be set default output to XML.
I try to trace this problem, and finally found the related variable is 'rest_server_default_response_format'.
and the related code on services module is getResponseFormatContentTypeNegotiations
So i have $mime_candidates[] value
Array ( [0] => application/xml [1] => text/xml [2] => application/json )
Even the response_format already set as json on line 87, but the mimeparse->best_match() return 'text/xml'.
what the best way to override this?
i don't think edit the getResponseFormatContentTypeNegotiations is the best way.
is there anyway to make the best_match function prefer format JSON than XML?
thank you.