hack-2009.4.51: a sexy Haskell Webserver Interface



Hack spec! Stolen from Rack with some simplification.



type Map = [(String, String)]Source

type HackErrors = StreamSource

customizable error stream

data Env Source




request_method :: RequestMethod

HTTP request method

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

path_info :: 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 "/"

query_string :: String

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

server_name :: 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

server_port :: 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 :: Map

Variables corresponding to the client-supplied HTTP request headers

hack_version :: [Int]

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

hack_url_scheme :: Hack_UrlScheme

HTTP or HTTPS, depending on the request URL

hack_input :: String

body of the request

hack_errors :: HackErrors

error stream

hack_multithread :: Bool

true if the application object may be simultaneously invoked by another thread in the same process, false otherwise.

hack_multiprocess :: Bool

true if an equivalent application object may be simultaneously invoked by another process, false otherwise.

hack_run_once :: Bool

true if the server expects (but does not guarantee!) that the application will only be invoked this one time during the life of its containing process. Normally, this will only be true for a server based on CGI (or something similar).

custom :: Map

any non HTTP standard header


data Response Source




status :: Int

must be greater than or equal to 100.

headers :: Map

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 :: String

body of the response