Cleanup config/routes.rb even further by extracting more routes into separate files

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2016-10-05 18:43:47 +03:00
parent ba4c392721
commit b9e259dded
No known key found for this signature in database
GPG key ID: 627C5F589F467F17
8 changed files with 65 additions and 66 deletions

View file

@ -9,33 +9,6 @@ class ActionDispatch::Routing::Mapper
end end
Rails.application.routes.draw do Rails.application.routes.draw do
if Gitlab::Sherlock.enabled?
namespace :sherlock do
resources :transactions, only: [:index, :show] do
resources :queries, only: [:show]
resources :file_samples, only: [:show]
collection do
delete :destroy_all
end
end
end
end
if Rails.env.development?
# Make the built-in Rails routes available in development, otherwise they'd
# get swallowed by the `namespace/project` route matcher below.
#
# See https://git.io/va79N
get '/rails/mailers' => 'rails/mailers#index'
get '/rails/mailers/:path' => 'rails/mailers#preview'
get '/rails/info/properties' => 'rails/info#properties'
get '/rails/info/routes' => 'rails/info#routes'
get '/rails/info' => 'rails/info#index'
mount LetterOpenerWeb::Engine, at: '/rails/letter_opener'
end
concern :access_requestable do concern :access_requestable do
post :request_access, on: :collection post :request_access, on: :collection
post :approve_access_request, on: :member post :approve_access_request, on: :member
@ -45,21 +18,9 @@ Rails.application.routes.draw do
post :toggle_award_emoji, on: :member post :toggle_award_emoji, on: :member
end end
namespace :ci do draw :sherlock
# CI API draw :development
Ci::API::API.logger Rails.logger draw :ci
mount Ci::API::API => '/api'
resource :lint, only: [:show, :create]
resources :projects, only: [:index, :show] do
member do
get :status, to: 'projects#badge'
end
end
root to: 'projects#index'
end
use_doorkeeper do use_doorkeeper do
controllers applications: 'oauth/applications', controllers applications: 'oauth/applications',
@ -82,36 +43,16 @@ Rails.application.routes.draw do
# JSON Web Token # JSON Web Token
get 'jwt/auth' => 'jwt#auth' get 'jwt/auth' => 'jwt#auth'
# API
API::API.logger Rails.logger
mount API::API => '/api'
constraint = lambda { |request| request.env['warden'].authenticate? and request.env['warden'].user.admin? }
constraints constraint do
mount Sidekiq::Web, at: '/admin/sidekiq', as: :sidekiq
end
# Health check # Health check
get 'health_check(/:checks)' => 'health_check#index', as: :health_check get 'health_check(/:checks)' => 'health_check#index', as: :health_check
# Help
get 'help' => 'help#index'
get 'help/shortcuts' => 'help#shortcuts'
get 'help/ui' => 'help#ui'
get 'help/*path' => 'help#show', as: :help_page
# Koding route # Koding route
get 'koding' => 'koding#index' get 'koding' => 'koding#index'
# Global snippets draw :api
resources :snippets, concerns: :awardable do draw :sidekiq
member do draw :help
get 'raw' draw :snippets
end
end
get '/s/:username', to: redirect('/u/%{username}/snippets'),
constraints: { username: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ }
# Invites # Invites
resources :invites, only: [:show], constraints: { id: /[A-Za-z0-9_-]+/ } do resources :invites, only: [:show], constraints: { id: /[A-Za-z0-9_-]+/ } do

2
config/routes/api.rb Normal file
View file

@ -0,0 +1,2 @@
API::API.logger Rails.logger
mount API::API => '/api'

15
config/routes/ci.rb Normal file
View file

@ -0,0 +1,15 @@
namespace :ci do
# CI API
Ci::API::API.logger Rails.logger
mount Ci::API::API => '/api'
resource :lint, only: [:show, :create]
resources :projects, only: [:index, :show] do
member do
get :status, to: 'projects#badge'
end
end
root to: 'projects#index'
end

View file

@ -0,0 +1,13 @@
if Rails.env.development?
# Make the built-in Rails routes available in development, otherwise they'd
# get swallowed by the `namespace/project` route matcher below.
#
# See https://git.io/va79N
get '/rails/mailers' => 'rails/mailers#index'
get '/rails/mailers/:path' => 'rails/mailers#preview'
get '/rails/info/properties' => 'rails/info#properties'
get '/rails/info/routes' => 'rails/info#routes'
get '/rails/info' => 'rails/info#index'
mount LetterOpenerWeb::Engine, at: '/rails/letter_opener'
end

4
config/routes/help.rb Normal file
View file

@ -0,0 +1,4 @@
get 'help' => 'help#index'
get 'help/shortcuts' => 'help#shortcuts'
get 'help/ui' => 'help#ui'
get 'help/*path' => 'help#show', as: :help_page

12
config/routes/sherlock.rb Normal file
View file

@ -0,0 +1,12 @@
if Gitlab::Sherlock.enabled?
namespace :sherlock do
resources :transactions, only: [:index, :show] do
resources :queries, only: [:show]
resources :file_samples, only: [:show]
collection do
delete :destroy_all
end
end
end
end

4
config/routes/sidekiq.rb Normal file
View file

@ -0,0 +1,4 @@
constraint = lambda { |request| request.env['warden'].authenticate? and request.env['warden'].user.admin? }
constraints constraint do
mount Sidekiq::Web, at: '/admin/sidekiq', as: :sidekiq
end

View file

@ -0,0 +1,8 @@
resources :snippets, concerns: :awardable do
member do
get 'raw'
end
end
get '/s/:username', to: redirect('/u/%{username}/snippets'),
constraints: { username: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ }