File tree Expand file tree Collapse file tree 4 files changed +18
-0
lines changed
Expand file tree Collapse file tree 4 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 1+ synopsis: Fix build of examples/greet.hs. Add "429 Too Many Requests" error.
2+ prs: #1591
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import Network.Wai.Handler.Warp
1818
1919import Servant
2020import Servant.Server.Generic ()
21+ import Servant.API.Generic ((:-) )
2122
2223-- * Example
2324
Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ module Servant.Server
8484 , err417
8585 , err418
8686 , err422
87+ , err429
8788 -- ** 5XX
8889 , err500
8990 , err501
Original file line number Diff line number Diff line change @@ -392,6 +392,20 @@ err422 = ServerError { errHTTPCode = 422
392392 , errHeaders = []
393393 }
394394
395+ -- | 'err429' Too Many Requests
396+ --
397+ -- Example:
398+ --
399+ -- > failingHandler :: Handler ()
400+ -- > failingHandler = throwError $ err429 { errBody = "You have sent too many requests in a short period of time." }
401+ --
402+ err429 :: ServerError
403+ err429 = ServerError { errHTTPCode = 429
404+ , errReasonPhrase = " Too Many Requests"
405+ , errBody = " "
406+ , errHeaders = []
407+ }
408+
395409-- | 'err500' Internal Server Error
396410--
397411-- Example:
You can’t perform that action at this time.
0 commit comments