Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[servant-server] Add error 429 Too Many Requests. Fix build of examples/greet.hs #1591

Merged
merged 4 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.d/1591
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
synopsis: Fix build of examples/greet.hs. Add "429 Too Many Requests" error.
prs: #1591
1 change: 1 addition & 0 deletions servant-server/example/greet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Network.Wai.Handler.Warp

import Servant
import Servant.Server.Generic ()
import Servant.API.Generic ((:-))

-- * Example

Expand Down
1 change: 1 addition & 0 deletions servant-server/src/Servant/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ module Servant.Server
, err417
, err418
, err422
, err429
-- ** 5XX
, err500
, err501
Expand Down
14 changes: 14 additions & 0 deletions servant-server/src/Servant/Server/Internal/ServerError.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading