[eluser]MikeVrind[/eluser]
I just started working this again after a little busy period.
I have the route added to the routes file. This worked very easy!
Only I used a slightly different approach for the route:
Code:
$route['json/(:any)'] = "$1/";
I Router I then made a small adjustment to determine the request method.
This gives me the opportunity to use the router for getting the requestmethod.
Code:
$this->router->requestFormat
The default value of this var is HTML, but could be set to json or something else.
Judging by your example I should build a switch in every controller? This seems a bit awkward because it goes completely against the DRY (Dont repeat yourself) principle.
I'm just still looking into the framework for the best way to implement the final step, depending on the application method, outputing the data in the correct way (As HTML or JSON string).
Because I also want to add Twig as an template parser in the framework, I'm thinking of building a custom 'Output' classe that calls Twig in case of an HTML request and used json_encode() in case of an JSON request.