Currently rest_server module may parse the response formatter from the request URL. It simply checks if the URL has an file extension registers the formatter from there and removes it from the end of the request.

See RESTServer::getResponseFormatter and RESTServer::getResponseFormatFromURL.

This may not be wanted behaviour. In my case I wanted to use a filename as a parameter like this /api/2/test.png. I didn't understand why it didn't work. It ended up with an error: "Unknown or unsupported response format."

After inspecting the code I realised what was happening but I didn't find an easy way to turn this feature off. Is it possible to make this feature optional? Also is there any easy way to extend the RESTServer in my custom module to change some of it's behaviour?

Comments

jiv_e created an issue. See original summary.

kylebrowning’s picture

Category: Feature request » Support request

You could copy and paste rest_server module, and change the functionality you want, and then enable that server not he endpoint.

http://cgit.drupalcode.org/services/tree/docs/services.servers.api.php

Services will not be implementing this so I am changing this to a support ticket.

jiv_e’s picture

Status: Active » Closed (won't fix)

Thank you for your response!

Yes, that's something I considered. It seems a little bit overkill to do it that way. I would also loose any updates done on RESTServer code.

I ended up using query parameters. It would still be cleaner to use path parameters though, but not worth it I think.

Thanks!

kylebrowning’s picture

To be fair @jiv_e we haven't changed RESTServer in a long time.