I'm starting now with REST (using Laravel 4.2) and Mobile (Android, iOS, SP, etc.) applications.
Initially I'm checking if the request is ajax/json and then return a json response.
But this condition is in a normal action (HTTP), so:
if ajax/json return json, else return the view/template/layout
Is it correct to do that in the same action, or is the best practice to create another controller for that? For example:
- Mobile\PostsController (or Json\Controller) - using namespaces