Project

General

Profile

« Previous | Next » 

Revision 2807589b

Added by Corey Osman almost 12 years ago

  • ID 2807589bd5fc7f5d5d9cf00606181fa9b9136971

split api routes to separate routes file

View differences:

config/application.rb
module Foreman
class Application < Rails::Application
# Setup additional routes by loading all routes file from routes directory
config.paths.config.routes.concat Dir[Rails.root.join("config/routes/*.rb")]
# Setup api routes by loading all routes file from routes/api directory
config.paths.config.routes.concat Dir[Rails.root.join("config/routes/api/*.rb")]
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
config/routes.rb
resources :tasks, :only => [:show]
#### API Namespace from here downwards ####
restapi
namespace :api, :defaults => {:format => 'json'} do
scope :module => :v1, :constraints => ApiConstraints.new(:version => 1, :default => true) do
resources :bookmarks, :except => [:new, :edit]
resources :architectures, :except => [:new, :edit]
resources :operatingsystems, :except => [:new, :edit] do
member do
get 'bootfiles'
end
end
match '/', :to => 'home#index'
match 'status', :to => 'home#status', :as => "status"
end
# scope module: :v2, constraints: ApiConstraints.new(version: 2, default: true) do
# resources :bookmarks
# end
end
#Keep this line the last route
match '*a', :to => 'errors#routing'
config/routes/api/restapidoc.rb
# config/routes/api/restapidoc.rb
Rails.application.routes.draw do |map|
restapi
end
config/routes/api/v1.rb
# config/routes/api/v1.rb
Rails.application.routes.draw do |map|
namespace :api, :defaults => {:format => 'json'} do
scope :module => :v1, :constraints => ApiConstraints.new(:version => 1, :default => true) do
resources :bookmarks, :except => [:new, :edit]
resources :architectures, :except => [:new, :edit]
resources :operatingsystems, :except => [:new, :edit] do
member do
get 'bootfiles'
end
end
match '/', :to => 'home#index'
match 'status', :to => 'home#status', :as => "status"
end
#
end
end
config/routes/api/v2.rb
# config/routes/api/v1.rb
Rails.application.routes.draw do |map|
# namespace :api, :defaults => {:format => 'json'} do
# scope :module => :v2, :constraints => ApiConstraints.new(:version => 2, :default => false) do
# resources :bookmarks, :except => [:new, :edit]
# end
# end
end

Also available in: Unified diff