I have followed How to build a CakePHP 3 REST API tutorial to create REST API. Tutorial describes case when requests are made with extensions (json/xml) to set response format. Plugin CRUD for CakePHP is used.
I want to force JSON response format without using .json extension. I am getting MissingRouteException on my requests.
What have I tried
Router::prefix('api', function ($routes) {
//$routes->extensions(['json', 'xml']);
$routes->resources('Cocktails');
});
plus
#1
$this->RequestHandler->ext = 'json' into AppController::beforeFilter()
#2
$this->RequestHandler->renderAs($this, 'json'); into AppController::beforeFilter()
but this is trying to use template from Template/Api/Coctails/json
I want it to behave exactly like in the case with extension.
Thanks