Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

REST API file extension

I want to return responses depending on the file extension of the request made to my Rest API:

1 case - No extension like /api/robots/1 I 'd like to return response with XML

2 case - /api/case/1.json I'd like to return response in JSON

The same way i would like to return response in .txt and .html

What is the way phalcon would deal with it?

Could not find such topic, please advise


You can create routes where a parameter is the extension:

        "controller" => "documentation",
        "action"     => "show"