happstack-server-7.1.3: Web related tools and services.

PortabilityGHC-only, Windows, Linux, FreeBSD, OS X
MaintainerHappstack team <happs@googlegroups.com>
Safe HaskellNone




Happstack.Server provides a self-contained HTTP server and a rich collection of types and functions for routing Requests, generating Responses, working with query parameters, form data, and cookies, serving files and more.

A very simple, "Hello World!" web app looks like:

 import Happstack.Server
 main = simpleHTTP nullConf $ ok "Hello World!"

By default the server will listen on port 8000. Run the app and point your browser at: http://localhost:8000/

At the core of the Happstack server we have the simpleHTTP function which starts the HTTP server:

 simpleHTTP :: ToMessage a => Conf -> ServerPart a -> IO ()

and we have the user supplied ServerPart (also known as, ServerPartT IO), which generates a Response for each incoming Request.

A trivial HTTP app server might just take a user supplied function like:

 myApp :: Request -> IO Response

For each incoming Request the server would fork a new thread, run myApp to generate a Response, and then send the Response back to the client. But, that would be a pretty barren wasteland to work in.

The model for ServerPart is essential the same, except we use the much richer ServerPart monad instead of the IO monad.

For in-depth documentation and runnable examples I highly recommend The Happstack Crash Course http://happstack.com/docs/crashcourse/index.html.


HTTP Server

Request Routing

Creating Responses

Looking up values in Query String, Request Body, and Cookies

Create and Set Cookies (see also Happstack.Server.RqData)

File Serving

HTTP Realm Authentication

Error Handling


Web-related Monads


Output Validation

HTTP Types