On Tue, Mar 5, 2013 at 3:42 PM, <david_pater...@dell.com> wrote: > The routing pattern we use in CB2 needs to be finalized. Currently there are > a couple of different routing patterns in use which is going to lead to > problems down the road. > > Fact: We need to have two controllers per barclamp/managed object. One for > UI and another for API calls. There was an earlier discussion around using a > single controller for both UI and API, the output of this design discussion > is we need two.
Where did this discussion happen? > Please let's assume there will be two moving forward and limit the scope of > this thread to the routing pattern. > > As a starting place we could use namespaces. The UI would use the root > namespace and api calls would fall under a :api namespace that includes a > version scope. > > Example routes for Network Barclamp > > resources :networks #UI routes for networks, URL http:[host]:[port]/networks > > namespace :api > scope ':barclamp' do > scope ':version' do > resources :networks #Versioned API routes for networks , URL > http:[host]:[port]/api/network/v2/networks > resources :conduits #Versioned API routes for conduits, URL > http:[host]:[port]/api/network/v2/conduits > ... > end > end > end The scheme that Rob, Ward, Wayne and myself settled on looks like this (from the current routes.rb): # API routes (must be json and must prefix v2)() scope :defaults => {:format=> 'json'} do constraints(:id => /([a-zA-Z0-9\-\.\_]*)/, :version => /v[1-9]/ ) do # framework resources pattern (not barclamps specific) scope 'api' do scope 'status' do get "nodes(/:id)" => "nodes#status", :as=>:nodes_status get "deployments(/:id)" => "deployments#status", :as=>:deployments_status end scope ':version' do resources :nodes do resources :attribs resources :groups match 'transistion' # these should be limited to put, but being more lax for now match 'allocate' # these should be limited to put, but being more lax for now end resources :barclamps do resources :deployments end resources :deployments resources :snapshots resources :jigs #resources :users resources :attrib_types resources :attribs resources :role_types resources :roles resources :groups do member do get 'nodes' end end end # version end # api # Barclamp resource v2 API Pattern scope ':barclamp' do scope ':version' do match "template" => "barclamps#template" resources :deployments do member do put 'commit' put 'recall' end end resources :snapshots resources :roles do resources :attribs resources :nodes end resources :attribs end # version scope end # barclamp scope end # id constraints > The controllers would then be located in file system as follows: > [barclamp_root]/app/controllers/networks_controller.rb - UI Controller > [barclamp_root]/app/controllers/api/networks_controller.rb - API controller. > > There are other ways of doing, this is one idea. We need to settle on a > common scheme ASAP. > > Feedback please. > > > > > > _______________________________________________ > Crowbar mailing list > Crowbar@dell.com > https://lists.us.dell.com/mailman/listinfo/crowbar > For more information: http://crowbar.github.com/ _______________________________________________ Crowbar mailing list Crowbar@dell.com https://lists.us.dell.com/mailman/listinfo/crowbar For more information: http://crowbar.github.com/