warp-0.4.2: A fast, light-weight web server for WAI applications.




A fast, light-weight HTTP server handler for WAI. Some random notes (a FAQ, if you will):

  • When a ResponseFile indicates a file which does not exist, an exception is thrown. This will close the connection to the client as well. You should handle file existance checks at the application level.


Run a Warp server

run :: Port -> Application -> IO ()Source

Run an Application on the given port. This calls runSettings with defaultSettings.

runSettings :: Settings -> Application -> IO ()Source

Run a Warp server with the given settings.

runSettingsSocket :: Settings -> Socket -> Application -> IO ()Source

Same as runSettings, but uses a user-supplied socket instead of opening one. This allows the user to provide, for example, Unix named socket, which can be used when reverse HTTP proxying into your application.

Note that the settingsPort will still be passed to Applications via the serverPort record.


data Settings Source

Various Warp server settings. This is purposely kept as an abstract data type so that new settings can be added without breaking backwards compatibility. In order to create a Settings value, use defaultSettings and record syntax to modify individual records. For example:

 defaultSettings { settingsTimeout = 20 }

defaultSettings :: SettingsSource

The default settings for the Warp server. See the individual settings for the default value.

settingsPort :: Settings -> IntSource

Port to listen on. Default value: 3000

settingsHost :: Settings -> StringSource

Host to bind to, or * for all. Default value: *

settingsOnException :: Settings -> SomeException -> IO ()Source

What to do with exceptions thrown by either the application or server. Default: ignore server-generated exceptions (see InvalidRequest) and print application-generated applications to stderr.

settingsTimeout :: Settings -> IntSource

Timeout value in seconds. Default value: 30



data Manager Source

A timeout manager



:: Int

timeout in microseconds

-> (Manager -> IO a) 
-> IO a 

Call the inner function with a timeout manager.

pause :: Handle -> IO ()Source

resume :: Handle -> IO ()Source