diff --git a/app/controllers/api/v1/deprecated_controller.rb b/app/controllers/api/v1/deprecated_controller.rb index b9e07214..3269a1a8 100644 --- a/app/controllers/api/v1/deprecated_controller.rb +++ b/app/controllers/api/v1/deprecated_controller.rb @@ -2,11 +2,11 @@ module Api module V1 class DeprecatedController < ApplicationController - # rubocop:disable Style/MethodMissing - def method_missing - render json: { error: '/api/v1 is deprecated! Please use /api/v2 instead.' } + def deprecated + render json: { + error: '/api/v1 has been deprecated! Please use /api/v2 instead.' + }, status: :gone end - # rubocop:enable Style/MethodMissing end end end diff --git a/app/controllers/api/v1/mappings_controller.rb b/app/controllers/api/v1/mappings_controller.rb deleted file mode 100644 index 8ba6e704..00000000 --- a/app/controllers/api/v1/mappings_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true -module Api - module V1 - class MappingsController < DeprecatedController - end - end -end diff --git a/app/controllers/api/v1/maps_controller.rb b/app/controllers/api/v1/maps_controller.rb deleted file mode 100644 index 0ff6f472..00000000 --- a/app/controllers/api/v1/maps_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true -module Api - module V1 - class MapsController < DeprecatedController - end - end -end diff --git a/app/controllers/api/v1/synapses_controller.rb b/app/controllers/api/v1/synapses_controller.rb deleted file mode 100644 index 32522e52..00000000 --- a/app/controllers/api/v1/synapses_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true -module Api - module V1 - class SynapsesController < DeprecatedController - end - end -end diff --git a/app/controllers/api/v1/tokens_controller.rb b/app/controllers/api/v1/tokens_controller.rb deleted file mode 100644 index 9df2094a..00000000 --- a/app/controllers/api/v1/tokens_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true -module Api - module V1 - class TokensController < DeprecatedController - end - end -end diff --git a/app/controllers/api/v1/topics_controller.rb b/app/controllers/api/v1/topics_controller.rb deleted file mode 100644 index d316bfa8..00000000 --- a/app/controllers/api/v1/topics_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true -module Api - module V1 - class TopicsController < DeprecatedController - end - end -end diff --git a/app/controllers/api/v2/restful_controller.rb b/app/controllers/api/v2/restful_controller.rb index 5d8f81b3..b64682f3 100644 --- a/app/controllers/api/v2/restful_controller.rb +++ b/app/controllers/api/v2/restful_controller.rb @@ -29,6 +29,11 @@ module Api head :no_content end + def catch_404 + skip_authorization + render json: { error: '404 Not found' }, status: :not_found + end + private def accessible_records diff --git a/config/routes.rb b/config/routes.rb index 05fe5845..b5078d86 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -77,18 +77,13 @@ Metamaps::Application.routes.draw do resources :users, only: [:index, :show] do get :current, on: :collection end + match '*path', to: 'restful#catch_404', via: :all end namespace :v1, path: '/v1' do - # api v1 routes all lead to a deprecation error method - # see app/controllers/api/v1/deprecated_controller.rb - resources :maps, only: [:create, :show, :update, :destroy] - resources :synapses, only: [:create, :show, :update, :destroy] - resources :topics, only: [:create, :show, :update, :destroy] - resources :mappings, only: [:create, :show, :update, :destroy] - resources :tokens, only: [:create, :destroy] do - get :my_tokens, on: :collection - end + root to: 'deprecated#deprecated', via: :all + match '*path', to: 'deprecated#deprecated', via: :all end + match '*path', to: 'v2/restful#catch_404', via: :all end devise_for :users, skip: :sessions, controllers: {