Commits

Luke Plant committed fd11f83

s/method/requestMethod/, s/path/pathInfo/ and changed implementation

  • Participants
  • Parent commits f2f39c2

Comments (0)

Files changed (2)

File src/Web/Request.hs

-module Web.Request (method, path, environment, mkRequest)
+module Web.Request (requestMethod, pathInfo, environment, mkRequest)
 
 where
 
 import qualified Data.Map as Map
 import Data.Maybe
 
-data Request = Request { method :: String
-                       , path :: String
-                       , environment :: Map.Map String String
-                       } deriving (Show, Read, Eq, Ord)
+data Request = Request {
+      environment :: Map.Map String String
+    } deriving (Show, Read, Eq, Ord)
 
 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
-                             , environment = envMap
+                               environment = envMap
                              }
+
+requestMethod request = fromJust $ Map.lookup "REQUEST_METHOD" $ environment request
+pathInfo request = fromJust $ Map.lookup "PATH_INFO" $ environment request

File testsuite/tests/Tests/Web/Request.hs

 
 where
 
-import qualified Web.Request as R
-import Web.Request (mkRequest)
+import Web.Request
 import Test.HUnit
 
-testMethod = "GET" ~=? R.method (mkRequest [("REQUEST_METHOD","GET")] "")
-testPath = "/foo/bar" ~=? R.path (mkRequest [("PATH_INFO", "/foo/bar")] "")
+testMethod = "GET" ~=? requestMethod (mkRequest [("REQUEST_METHOD","GET")] "")
+testPath = "/foo/bar" ~=? pathInfo (mkRequest [("PATH_INFO", "/foo/bar")] "")
 
 tests = test [
          testMethod,