hack-2009.5.19: a sexy Haskell Webserver Interface

Hack

Description

Hack spec! Stolen from Rack with some simplification.

Synopsis

Documentation

type HackErrors = String -> IO ()Source

customizable error stream

data Env Source

Constructors

Env 

Fields

requestMethod :: RequestMethod

HTTP request method

scriptName :: String

The initial portion of the request URL's "path" that corresponds to the application object, so that the application knows its virtual "location". This may be an empty string, if the application corresponds to the "root" of the server.

pathInfo :: String

The remainder of the request URL's "path", designating the virtual "location" of the request's target within the application. This will always starts with "/"

queryString :: String

The portion of the request URL that follows the ?, if any. May be empty

serverName :: String

When combined with SCRIPT_NAME and PATH_INFO, these variables can be used to complete the URL. Note, however, that HTTP_HOST, if present, should be used

serverPort :: Int

preference to SERVER_NAME for reconstructing the request URL. SERVER_NAME and SERVER_PORT can never be empty strings, and so are always required.

http :: [(String, String)]

All http header variables.

hackVersion :: [Int]

The Array [0,1], representing this version of Hack

hackUrlScheme :: Hack_UrlScheme

HTTP or HTTPS, depending on the request URL

hackInput :: ByteString

body of the request

hackErrors :: HackErrors

error stream

hackHeaders :: [(String, String)]

custom headers, intended to be used by middleware

Instances

data Response Source

Constructors

Response 

Fields

status :: Int

must be greater than or equal to 100.

headers :: [(String, String)]

The header must not contain a Status key, contain keys with : or newlines in their name, contain keys names that end in - or _, but only contain keys that consist of letters, digits, _ or - and start with a letter. The values of the header must be Strings, consisting of lines (for multiple header values) seperated by "\n". The lines must not contain characters below 037.

body :: ByteString

body of the response