second-transfer-0.1.0.0: Second Transfer HTTP/2 web server

Safe HaskellNone
LanguageHaskell2010

SecondTransfer.MainLoop

Contents

Synopsis

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.

data IOProblem Source

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.

tlsServeWithALPN Source

Arguments

:: 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 Attendant to use for each. This way you can serve both HTTP/1.1 over TLS and HTTP/2 in the same socket.

-> Int

Port to open to listen for connections.

-> IO () 

Simple function to open

tlsServeWithALPNAndFinishOnRequest Source

Arguments

:: FilePath 
-> FilePath

Same as for tlsServeWithALPN

-> String

Same as for tlsServeWithALPN

-> [(String, Attendant)]

Same as for tlsServeWithALPN

-> Int

Same as for tlsServeWithALPN

-> 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.

Constructors

FinishRequest