http-server-1.0.6: A library for writing Haskell web servers.

Copyright(c) Galois, Inc. 2007, 2008
LicenseBSD3
Maintainerdiatchki@galois.com
Stabilityprovisional
Portability
Safe HaskellNone
LanguageHaskell98

Network.HTTP.Server

Description

 

Synopsis

Documentation

server :: HStream a => Handler a -> IO () Source

Start a server with the default configuration, and the given handler. Requests are handled in separate threads.

serverWith :: HStream a => Config -> Handler a -> IO () Source

Start a server with the given configuration and handler. Requests are handled in separate threads.

type Handler a = SockAddr -> URL -> Request a -> IO (Response a) Source

Handlers invoked to process requests. The type parameter is for the type of the payload in the body. It is a variation on string of some sort (e.g., String, ByteString, etc.)

data Config Source

Server configuration.

Constructors

Config 

Fields

srvLog :: Logger

Server reports what's going on here.

srvHost :: HostName

Host name to bind to.

srvPort :: PortNumber

Port to listen on.

defaultConfig :: Config Source

Some default options for a server: no logging output, listen on "localhost:8000".

data Request a :: * -> *

An HTTP Request. The Show instance of this type is used for message serialisation, which means no body data is output.

Constructors

Request 

Fields

rqURI :: URI

might need changing in future 1) to support * uri in OPTIONS request 2) transparent support for both relative & absolute uris, although this should already work (leave scheme & host parts empty).

rqMethod :: RequestMethod
 
rqHeaders :: [Header]
 
rqBody :: a
 

Instances

data Response a :: * -> *

An HTTP Response. The Show instance of this type is used for message serialisation, which means no body data is output, additionally the output will show an HTTP version of 1.1 instead of the actual version returned by a server.

Constructors

Response 

Instances

data RequestMethod :: *

The HTTP request method, to be used in the Request object. We are missing a few of the stranger methods, but these are not really necessary until we add full TLS.