Issue
I'm looking for a way to route URLs to different controllers depending on the value of the HTTP 'Accept' header.
All I have found so far is the official CakePHP documentation on routes but it is not very detailled.
Is this possible using route configurations or do I have to do this another way (e.g. by implementing a DispatcherFilter to inspect the CakeRequest)?
Solution
I want a set-up where I can seamlessly distribute responsibilities between server side and client side: e.g. letting the client handle the view creation instead of the server responding with an HTML document.
Guess you're using something like AngularJS? Well, then you expect a data format back instead of HTML I guess. So request application/json via the accept header and / or the extension. Cake can detect both and respond accordingly.
Read about JSON and XML views in the manual.
http://book.cakephp.org/2.0/en/views/json-and-xml-views.html
Answered By - floriank Answer Checked By - Marie Seifert (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.