Lucu-1.0: Embedded HTTP Server

Network.HTTP.Lucu.Httpd

Description

The entry point of Lucu httpd.

Synopsis

Documentation

runHttpd :: HostMapper α => Config -> α -> IO ()Source

This is the entry point of Lucu httpd. It listens to a socket and waits for clients. runHttpd never stops by itself so the only way to stop it is to raise an exception in the thread running it.

Example:

{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE QuasiQuotes #-} module Main where import qualified Data.Collections as C import Network import Network.HTTP.Lucu main :: IO () main = let config = defaultConfig tree :: ResourceTree tree = C.fromList [ ([], nonGreedy helloWorld) ] in Network.withSocketsDo . runHttpd config $ resourceMap tree helloWorld :: Network.HTTP.Lucu.Resource helloWorld = C.fromList [ ( Network.HTTP.Lucu.GET , do Network.HTTP.Lucu.setContentType [Network.HTTP.Lucu.mimeType| text/plain |] Network.HTTP.Lucu.putChunk "Hello, world!" } FIXME: use monad-parallel's MonadFork instead of IO.