From 02c7f68b4464b960e535f580377032a8093f5233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Meny?= Date: Fri, 4 Mar 2022 15:27:52 +0000 Subject: [PATCH] Add too many requests page --- app/controllers/errors_controller.rb | 7 +++++++ app/views/errors/too_many_requests.erb | 8 ++++++++ config/routes.rb | 1 + 3 files changed, 16 insertions(+) create mode 100644 app/views/errors/too_many_requests.erb diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index 6b5abfc42..6b4c63f65 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -22,4 +22,11 @@ class ErrorsController < ApplicationController format.json { render json: { error: "Unprocessable entity" }, status: :unprocessable_entity } end end + + def too_many_requests + respond_to do |format| + format.html { render status: :too_many_requests } + format.json { render json: { error: "Too many requests" }, status: :too_many_requests } + end + end end diff --git a/app/views/errors/too_many_requests.erb b/app/views/errors/too_many_requests.erb new file mode 100644 index 000000000..2e41652e7 --- /dev/null +++ b/app/views/errors/too_many_requests.erb @@ -0,0 +1,8 @@ +<% content_for :title, "Sorry, you have sent too many requests to our service" %> + +
+
+

<%= content_for(:title) %>

+

Try again in a minute.

+
+
diff --git a/config/routes.rb b/config/routes.rb index c9738f1e3..730145ee8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -71,6 +71,7 @@ Rails.application.routes.draw do scope via: :all do match "/404", to: "errors#not_found" + match "/429", to: "errors#too_many_requests" match "/422", to: "errors#unprocessable_entity" match "/500", to: "errors#internal_server_error" end