Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type Attendant = PushAction -> PullAction -> CloseAction -> IO ()
- type PullAction = IO ByteString
- type PushAction = ByteString -> IO ()
- type CloseAction = IO ()
- data IOProblem
- data GenericIOProblem
- tlsServeWithALPN :: FilePath -> FilePath -> String -> [(String, Attendant)] -> Int -> IO ()
- tlsServeWithALPNAndFinishOnRequest :: FilePath -> FilePath -> String -> [(String, Attendant)] -> Int -> MVar FinishRequest -> IO ()
- data TLSLayerGenericProblem = TLSLayerGenericProblem String
- data FinishRequest = FinishRequest
Callback types
type Attendant = PushAction -> PullAction -> CloseAction -> IO () Source
A function which takes three arguments: the first one says how to send data (on a socket or similar transport), and the second one how to receive data on said socket. The third argument encapsulates the sequence of steps needed for a clean shutdown.
You can implement one of these to let somebody else supply the push, pull and close callbacks. In this library we supply callbacks for TLS sockets, so that you don't need to go through the drudgery of managing those yourself.
type PullAction = IO ByteString Source
Callback type to pull data from a channel. The same as to PushAction applies to exceptions thrown from there.
type PushAction = ByteString -> IO () Source
Callback type to push data to a channel. Part of this interface is the abstract exception type IOProblem. Throw an instance of it to notify the session that the connection has been broken.
type CloseAction = IO () Source
Callback that the Session calls to realease resources associated with the channels. Take into account that your callback should be able to deal with non-clean shutdowns also, for example, if the connection to the remote peer is severed suddenly.
Throw exceptions derived from this (e.g, GenericIOProblem
below)
to have the HTTP/2 session to terminate gracefully.
data GenericIOProblem Source
A concrete case of the above exception. Throw one of this
if you don't want to implement your own type. Capture one
IOProblem
otherwise.
High level OpenSSL functions.
Use these functions to create your TLS-compliant HTTP/2 server in a snap.
:: FilePath | Path to a certificate the server is going to use to identify itself. Bear in mind that multiple domains can be served from the same HTTP/2 TLS socket, so please create the HTTP/2 certificate accordingly. |
-> FilePath | Path to the key of your certificate. |
-> String | Name of the network interface where you want to start your server |
-> [(String, Attendant)] | List of protocol names and the corresponding |
-> Int | Port to open to listen for connections. |
-> IO () |
Simple function to open
tlsServeWithALPNAndFinishOnRequest Source
:: FilePath | |
-> FilePath | Same as for |
-> String | Same as for |
-> [(String, Attendant)] | Same as for |
-> Int | Same as for |
-> MVar FinishRequest | Finish request |
-> IO () |
Interruptible version of tlsServeWithALPN
. Use the extra argument to notify
the server of finishing.
data TLSLayerGenericProblem Source
Exception inheriting from IOProblem
. This is thrown by the
OpenSSL subsystem to signal that the connection was broken or that
otherwise there was a problem at the SSL layer.
data FinishRequest Source
Singleton type. Used in conjunction with an MVar
. If the MVar is full,
the fuction tlsServeWithALPNAndFinishOnRequest
knows that it should finish
at its earliest convenience and call the CloseAction
for any open sessions.