We have written a very complex web application which has the following requirements:
- This is a API. Various versions of APIs can behave differently. We have to support the old version of the API for a while.
- There is a web client in the web client uses AJAX to get various data. 99% say XHR requests are similar to API requests, therefore, to support these XHR requests, the source code must be shared for the API. But for example, in the case of APIs, the login API should respond with cookies and JSON in the case of the web.
- Customers such as iPhone, iPad, Android phone, tablet, browser extension etc. have different types of behavioral platforms which may vary depending on what they are requesting.
One way of organizing this stuff was to think that the Koha HMVC cascading style is being extended to one level. For example:
src / htdocs / v1 / device_group_phone / device_iphone / controller / ideas / device_android / controller / ideas / device_default / conrollers / ideas / device_group_tablet / device_ipad / controller / ideas / device_default / Corollers / ideas / device_group_default / controller / ideas / model / v2 / ... ... ... module / system /
The way a request should be presented: < / P>
- Go to the proper version - if there is an administrator / view device (x), then load it. Otherwise, if the controller / view is present for device_group (x) / device_default, then load it. And if there exists a controller / view_group_default then load it.
- The first question, is there a better way to organize this code?
- The second question, if not, how to do this in Kohana?
Why not use existing Kohana Cascade File? Your groups are Module , just add the necessary modules (via
Kohana :: modules () , depending on the request properties). Therefore, if you want to handle Android device, the module list will be as follows:
- v1 / device_group_phone / device_android
- v2 / device_group_phone/ device_android < Li> v1 / device_group_phone / device_default
- v2 / device_group_phone / device_default
- v1 / device_group_default
- v2 / device_group_default
Comments
Post a Comment