@@ -1,7 +1,4 @@
1-- | Timeout requests
1-- | Timeout requests
5module Network.Wai.Middleware.Timeout
2module Network.Wai.Middleware.Timeout
7 , timeoutStatus
4 , timeoutStatus
@@ -17,14 +14,19 @@ import qualified System.Timeout as Timeout
17-- Timeouts respond with @'status503'@. See @'timeoutStatus'@ or @'timeoutAs'@
14-- Timeouts respond with @'status503'@. See @'timeoutStatus'@ or @'timeoutAs'@
18-- to customize the behavior of the timed-out case.
15-- to customize the behavior of the timed-out case.
20timeout :: Int -> Middleware
18timeout :: Int -> Middleware
21timeout = timeoutStatus status503
19timeout = timeoutStatus status503
23-- | Time out with the given @'Status'@
21-- | Time out with the given @'Status'@
24timeoutStatus :: Status -> Int -> Middleware
24timeoutStatus :: Status -> Int -> Middleware
25timeoutStatus status = timeoutAs $ responseLBS status [] ""
25timeoutStatus status = timeoutAs $ responseLBS status [] ""
27-- | Time out with the given @'Response'@
27-- | Time out with the given @'Response'@
28timeoutAs :: Response -> Int -> Middleware
30timeoutAs :: Response -> Int -> Middleware
29timeoutAs timeoutReponse seconds app req respond =
31timeoutAs timeoutReponse seconds app req respond =
30 maybe (respond timeoutReponse) pure
32 maybe (respond timeoutReponse) pure