Issue
Some example rails/angularjs apps I have seen keep the API under its own namespace. These controllers only respond with json. I don't understand why these require their own namespace given that controller actions are intended to be able to respond to different types (html,js).
For example https://github.com/mkwiatkowski/todo-rails4-angularjs
Solution
I keep my API separate because my controllers return HTML. I know it is easy to return different formats from the controller, but once you start getting a lot of different formats in the controller it quickly starts taking up a lot of space and subtracts from the actual controller logic.
Another reason, perhaps even more important, is versioning. With an API you generally have clients which may be out of your control. It's much easier to provide support for different versions of APIs when you have them namespaced outside of the standard controller. This way, if you have a breaking change, you are able to just create a new version and not worry about older clients which might have not been updated yet.
Answered By - lightswitch05
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.