Commits

Luke Plant  committed 2d5b477

Made buildCGIRequest take RequestOptions, not just Encoding, and fixed some comments

  • Participants
  • Parent commits 07bea24

Comments (0)

Files changed (2)

File src/Web/Framework.hs

 -- | Handle a CGI request using a list of possible views
 -- If a view returns 'Nothing' the next will be tried,
 -- and a 404 issued if all return nothing
-dispatchCGI :: [View] -- list of views functions that will be tried in order
-            -> DispatchOptions                  -- options to use in dispatching
+dispatchCGI :: [View]           -- ^ list of views functions that will be tried in order
+            -> DispatchOptions  -- ^ options to use in dispatching
             -> IO ()
 dispatchCGI views opts = do
-  req <- buildCGIRequest (encoding $ requestOptions opts)
+  req <- buildCGIRequest (requestOptions opts)
   resp' <- dispatchRequest req views
   resp <- case resp' of
             Nothing -> notFoundHandler opts $ req
             Just x -> return x
   BS.hPut stdout (formatResponse resp)
 
+-- Routing
+
 -- $routing
 --
 -- The routing mechanism has been designed so that you can write code like the following:
 -- where View = Request -> IO (Maybe Response)
 
 -- The left hand argument of '//->' is a \'matcher\' - it parses the
--- 'path' of the Request, optionally capturing parameters and
--- returning a function that will adapt the right hand argument so
--- that it has type View.
+-- path of the Request, optionally capturing parameters and returning
+-- a function that will adapt the right hand argument so that it has
+-- type View.
 --
 -- Matchers can be composed using '</>'.  To match a fixed string
 -- without capturing, use @fixedString "thestring"@. The operators
--- </+> amd <+/> are useful to combining fixed strings with other
+-- </+> amd <+/> are useful for combining fixed strings with other
 -- matchers.  To match just a fixed string, you can use
 --
 -- > "thestring/" <+/> empty

File src/Web/Request.hs

 
 
 -- | Creates a Request object according to the CGI protocol
-buildCGIRequest :: Encoding -> IO Request
-buildCGIRequest encoding = do
+buildCGIRequest :: RequestOptions -- ^ options which determine how the HTTP request is interpreted
+                -> IO Request
+buildCGIRequest opts = do
   env <- getEnvironment
   body <- BS.hGetContents stdin
-  return $ mkRequest env body encoding
+  return $ mkRequest env body (encoding opts)