1. Luke Plant
  2. haskellblog

Commits

Luke Plant  committed db1f3e2

Added environment to Request, made Request abstract

  • Participants
  • Parent commits 5463df3
  • Branches default

Comments (0)

Files changed (1)

File src/Web/Request.hs

View file
-module Web.Request
+module Web.Request (method, path, environment, mkRequest)
 
 where
 
 import qualified Data.Map as Map
 import Data.Maybe
 
-data Request = Request { method :: String,
-                         path :: String}
+data Request = Request { method :: String
+                       , path :: String
+                       , environment :: Map.Map String String
+                       }
 
 mkRequest :: [(String, String)] -> String -> Request
 mkRequest env stdin = let envMap = Map.fromList env
                       in Request { 
-                               method = fromJust $ Map.lookup "REQUEST_METHOD" envMap,
-                               path = fromJust $ Map.lookup "PATH_INFO" envMap
+                               method = fromJust $ Map.lookup "REQUEST_METHOD" envMap
+                             , path = fromJust $ Map.lookup "PATH_INFO" envMap
+                             , environment = envMap
                              }