I created the routes shown below:
Router::connect('/:api/:controller/:action/*', array(), array('api'=>'api')); Router::connect('/:api/:controller', array('action' => 'index'), array('api'=>'api')); Router::connect('/:api/', array('controller' => 'index', 'action' => 'index'), array('api'=>'api'));
Basically, I want all requests made through a specific endpoint to respond in JSON. In the case above all requests made with the api prefix. For instance:
http:
Should return a JSON response instead of HTML. Note that it should work this way even if the .json extension is not defined.
source share