Commits

Luke Plant  committed 3e56df5

Added 'hasGET' and 'hasPOST' accessors for Request object

  • Participants
  • Parent commits 4e0e213

Comments (0)

Files changed (1)

File src/Ella/Request.hs

                    , allGET
                    , getPOST
                    , getPOSTlist
+                   , hasPOST
                    , getGET
                    , getGETlist
+                   , hasGET
                    , getCookieVal
                    , allCookies
                    , files
 getPOSTlist :: Request -> String -> [String]
 getPOSTlist req name = getMatching name (allPOST req)
 
+-- | returns True if the specified key is found in the
+-- Request POST values
+hasPOST :: Request -> String -> Bool
+hasPOST req name = Map.member name $ _postInputMap req
+
 -- | Retrieve a single query string value (last one wins if there are multiple)
 getGET :: Request -> String -> Maybe String
 getGET req name = Map.lookup name $ _getInputMap req
 getGETlist :: Request -> String -> [String]
 getGETlist req name = getMatching name (allGET req)
 
+-- | returns True if the specified key is found in the
+-- Request query string paramaters
+hasGET :: Request -> String -> Bool
+hasGET req name = Map.member name $ _getInputMap req
 
 -- | Retrieve the value of a cookie
 getCookieVal req name = lookup name $ allCookies req