diff --git a/config/routes.rb b/config/routes.rb index c9c46204c..9537b5821 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,23 +2,39 @@ Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html - user_is_admin = ->(req) { User.find_by(id: req.session[:user])&.administrator? } + # Home root to: 'homes#show' - resource :health, only: [:show] resource :home, only: [:show] - resource :phi_x, only: [:show] do - scope module: :phi_x do - resources :stocks - resources :spiked_buffers - end - end + # Health check endpoints + get 'health' => 'health#show', constraints: ->(req) { req.format == :json } # json with stats + get 'health' => 'rails/health#show', as: :rails_health_check # default Rails health check # Error handling endpoints get '/404', to: 'errors#not_found' get '/500', to: 'errors#internal_server_error' get '/503', to: 'errors#service_unavailable' + # Session authentication endpoints + match '/login' => 'sessions#login', :as => :login, :via => %i[get post] + match '/logout' => 'sessions#logout', :as => :logout, :via => %i[get post] + # this is for test only test/functional/authentication_controller_test.rb + # to be removed? + get 'authentication/open' + get 'authentication/restricted' + + # Feature flags + user_is_admin = ->(req) { User.find_by(id: req.session[:user])&.administrator? } + mount Flipper::UI.app => '/flipper', :constraints => user_is_admin + + # Search + resources :searches + resources :lab_searches + + get 'advanced_search' => 'advanced_search#index' + post 'advanced_search/search' => 'advanced_search#search' + + # API v1 mount Api::RootService.new => '/api/1' unless ENV['DISABLE_V1_API'] # @todo Update v2 resources exceptions to reflect resources (e.g., `, except: %i[update]` for `lot`), @@ -141,9 +157,6 @@ end end - match '/login' => 'sessions#login', :as => :login, :via => %i[get post] - match '/logout' => 'sessions#logout', :as => :logout, :via => %i[get post] - resources :plate_summaries, only: %i[index show] do collection { get :search } end @@ -344,8 +357,6 @@ end end - resources :searches - namespace :admin do resources :abilities, only: :index resources :custom_texts @@ -449,12 +460,8 @@ end end - resources :lab_searches resources :events - get 'advanced_search' => 'advanced_search#index' - post 'advanced_search/search' => 'advanced_search#search' - resources :workflows, only: [] do member do # Yes, this is every bit as horrible as it looks. @@ -468,6 +475,13 @@ collection { get :generate_manifest } end + resource :phi_x, only: [:show] do + scope module: :phi_x do + resources :stocks + resources :spiked_buffers + end + end + resources :asset_audits resources :qc_reports, except: %i[delete update] do @@ -627,11 +641,6 @@ resources :location_reports, only: %i[index show create] - # this is for test only test/functional/authentication_controller_test.rb - # to be removed? - get 'authentication/open' - get 'authentication/restricted' - resources :messengers, only: :show # We removed workflows, which broke study links. Some customers may have their own studies bookmarked @@ -646,8 +655,6 @@ end end - mount Flipper::UI.app => '/flipper', :constraints => user_is_admin - # Custom standalone route for bioscan control locations, allowing only # the POST request, migrated from the Lighthouse pickings endpoint. post 'bioscan_control_locations', to: 'bioscan_control_locations#create'