From 678b3edec667f9fc16eb632bd18882686f051e96 Mon Sep 17 00:00:00 2001 From: Daniel Casanueva Date: Sat, 28 May 2022 17:35:57 +0200 Subject: [PATCH] Add error 429: Too Many Requests --- servant-server/src/Servant/Server.hs | 1 + .../src/Servant/Server/Internal/ServerError.hs | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/servant-server/src/Servant/Server.hs b/servant-server/src/Servant/Server.hs index 79d092b9..07d5fb91 100644 --- a/servant-server/src/Servant/Server.hs +++ b/servant-server/src/Servant/Server.hs @@ -84,6 +84,7 @@ module Servant.Server , err417 , err418 , err422 + , err429 -- ** 5XX , err500 , err501 diff --git a/servant-server/src/Servant/Server/Internal/ServerError.hs b/servant-server/src/Servant/Server/Internal/ServerError.hs index 5b5d56e2..650f6e10 100644 --- a/servant-server/src/Servant/Server/Internal/ServerError.hs +++ b/servant-server/src/Servant/Server/Internal/ServerError.hs @@ -392,6 +392,20 @@ err422 = ServerError { errHTTPCode = 422 , errHeaders = [] } +-- | 'err429' Too Many Requests +-- +-- Example: +-- +-- > failingHandler :: Handler () +-- > failingHandler = throwError $ err429 { errBody = "You have sent too many requests in a short period of time." } +-- +err429 :: ServerError +err429 = ServerError { errHTTPCode = 429 + , errReasonPhrase = "Too Many Requests" + , errBody = "" + , errHeaders = [] + } + -- | 'err500' Internal Server Error -- -- Example: