on master help sign in
Add client socket address information to settingsOnClose.
df3c60fN. K. Michalopulos
warp/Network/Wai/Handler/Warp/Run.hs+1−1
@@ -185,7 +185,7 @@ runSettingsConnectionMaker set getConnMaker app = do
185 handle (onE Nothing) .
185 handle (onE Nothing) .
186
186
187 -- Call the user-supplied code for connection open and close events
187 -- Call the user-supplied code for connection open and close events
188− bracket (onOpen addr) (const onClose) $ \goingon ->
188+ bracket (onOpen addr) (const $ onClose addr) $ \goingon ->
189
189
190 -- Actually serve this connection.
190 -- Actually serve this connection.
191 -- onnClose above ensures the termination of the connection.
191 -- onnClose above ensures the termination of the connection.
warp/Network/Wai/Handler/Warp/Settings.hs+2−2
@@ -33,7 +33,7 @@ data Settings = Settings
33 --
33 --
34 -- Since 2.0.3
34 -- Since 2.0.3
35 , settingsOnOpen :: SockAddr -> IO Bool -- ^ What to do when a connection is open. When 'False' is returned, the connection is closed immediately. Otherwise, the connection is going on. Default: always returns 'True'.
35 , settingsOnOpen :: SockAddr -> IO Bool -- ^ What to do when a connection is open. When 'False' is returned, the connection is closed immediately. Otherwise, the connection is going on. Default: always returns 'True'.
36− , settingsOnClose :: IO () -- ^ What to do when a connection is close. Default: do nothing.
36+ , settingsOnClose :: SockAddr -> IO () -- ^ What to do when a connection is close. Default: do nothing.
37 , settingsTimeout :: Int -- ^ Timeout value in seconds. Default value: 30
37 , settingsTimeout :: Int -- ^ Timeout value in seconds. Default value: 30
38 , settingsIntercept :: Request -> Maybe (Source IO S.ByteString -> Connection -> IO ())
38 , settingsIntercept :: Request -> Maybe (Source IO S.ByteString -> Connection -> IO ())
39 , settingsManager :: Maybe Manager -- ^ Use an existing timeout manager instead of spawning a new one. If used, 'settingsTimeout' is ignored. Default is 'Nothing'
39 , settingsManager :: Maybe Manager -- ^ Use an existing timeout manager instead of spawning a new one. If used, 'settingsTimeout' is ignored. Default is 'Nothing'
@@ -65,7 +65,7 @@ defaultSettings = Settings
65 , settingsOnException = defaultExceptionHandler
65 , settingsOnException = defaultExceptionHandler
66 , settingsOnExceptionResponse = defaultExceptionResponse
66 , settingsOnExceptionResponse = defaultExceptionResponse
67 , settingsOnOpen = const $ return True
67 , settingsOnOpen = const $ return True
68− , settingsOnClose = return ()
68+ , settingsOnClose = const $ return ()
69 , settingsTimeout = 30
69 , settingsTimeout = 30
70 , settingsIntercept = const Nothing
70 , settingsIntercept = const Nothing
71 , settingsManager = Nothing
71 , settingsManager = Nothing