From d33733860b05d50d8c73e62384f4b25d8dfccd58 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Tue, 14 May 2019 22:34:47 +0200 Subject: [PATCH] warning with graphql get requests. #270 --- app/controllers/index_controller.rb | 5 +++++ config/routes.rb | 2 ++ 2 files changed, 7 insertions(+) diff --git a/app/controllers/index_controller.rb b/app/controllers/index_controller.rb index 1417139d6..40c364f17 100644 --- a/app/controllers/index_controller.rb +++ b/app/controllers/index_controller.rb @@ -11,4 +11,9 @@ def index # def routing_error # fail ActionController::RoutingError # end + + def method_not_allowed + response.set_header('Allow', 'POST') + render json: { "message": "This endpoint only supports POST requests." }.to_json, status: :method_not_allowed + end end diff --git a/config/routes.rb b/config/routes.rb index d811383cf..d4c621b75 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,7 @@ Rails.application.routes.draw do post "/graphql", to: "graphql#execute" + get "/graphql", to: "index#method_not_allowed" + root :to => 'index#index' # authentication