hack-2009.4.20: src/Hack.hs
module Hack where
import Data.Default
data RequestMethod =
OPTIONS
| GET
| HEAD
| POST
| PUT
| DELETE
| TRACE
| CONNECT
deriving (Show, Read, Eq)
data Hack_UrlScheme = HTTP | HTTPS deriving (Show, Eq)
type Map = [(String, String)]
data Env = Env {
request_method :: RequestMethod,
script_name :: String,
path_info :: String,
query_string :: String,
server_name :: String,
server_port :: Int,
http_ :: Map,
hack_version :: [Int],
hack_url_scheme :: String,
hack_input :: String,
hack_errors :: String,
hack_multithread :: String,
hack_multiprocess :: String,
hack_run_once :: String,
custom :: Map
}
deriving (Show)
data Response = Response {
status :: Int,
headers :: Map,
body :: String
}
deriving (Show)
instance Default RequestMethod where
def = GET
instance Default Hack_UrlScheme where
def = HTTP
instance Default Bool where
def = False
instance Default Response where
def = Response def def def
instance Default Env where
def = Env def def def def def def def def def def def def def def def
type Application = Env -> IO Response
type MiddleWareParams = Map
type MiddleWare = MiddleWareParams -> Application -> Application