Minor naming isssue handled.

This commit is contained in:
Pär-Anders Aronsson 2012-01-29 21:11:31 +01:00
parent 4796ad77d4
commit 88c3b12c86

View File

@ -59,6 +59,7 @@ module Yesod.Handler
, sendWaiResponse , sendWaiResponse
-- * Setting headers -- * Setting headers
, setCookie , setCookie
, getExpires
, deleteCookie , deleteCookie
, setHeader , setHeader
, setLanguage , setLanguage
@ -120,7 +121,7 @@ module Yesod.Handler
import Prelude hiding (catch) import Prelude hiding (catch)
import Yesod.Internal.Request import Yesod.Internal.Request
import Yesod.Internal import Yesod.Internal
import Data.Time (UTCTime) import Data.Time (UTCTime, getCurrentTime, addUTCTime)
import Control.Exception hiding (Handler, catch, finally) import Control.Exception hiding (Handler, catch, finally)
import Control.Applicative import Control.Applicative
@ -629,6 +630,14 @@ setCookie :: SetCookie
-> GHandler sub master () -> GHandler sub master ()
setCookie = addHeader . AddCookie setCookie = addHeader . AddCookie
-- | Helper function for setCookieExpires value
getExpires :: Int -- ^ minutes
-> IO UTCTime
getExpires m = do
now <- liftIO getCurrentTime
return $ fromIntegral (m * 60) `addUTCTime` now
-- | Unset the cookie on the client. -- | Unset the cookie on the client.
-- --
-- Note: although the value used for key and path is 'Text', you should only -- Note: although the value used for key and path is 'Text', you should only
@ -638,6 +647,7 @@ deleteCookie :: Text -- ^ key
-> GHandler sub master () -> GHandler sub master ()
deleteCookie a = addHeader . DeleteCookie (encodeUtf8 a) . encodeUtf8 deleteCookie a = addHeader . DeleteCookie (encodeUtf8 a) . encodeUtf8
-- | Set the language in the user session. Will show up in 'languages' on the -- | Set the language in the user session. Will show up in 'languages' on the
-- next request. -- next request.
setLanguage :: Text -> GHandler sub master () setLanguage :: Text -> GHandler sub master ()
@ -783,25 +793,7 @@ yarToResponse renderHeaders (YARPlain s hs ct c sessionFinal) =
finalHeaders = renderHeaders hs ct sessionFinal finalHeaders = renderHeaders hs ct sessionFinal
finalHeaders' len = ("Content-Length", S8.pack $ show len) finalHeaders' len = ("Content-Length", S8.pack $ show len)
: finalHeaders : finalHeaders
{-
getExpires m = fromIntegral (m * 60) `addUTCTime` now
sessionVal =
case key' of
Nothing -> B.empty
Just key'' -> encodeSession key'' exp' host
$ Map.toList
$ Map.insert nonceKey (reqNonce rr) sessionFinal
hs' =
case key' of
Nothing -> hs
Just _ -> AddCookie
(clientSessionDuration y)
sessionName
(bsToChars sessionVal)
: hs
hs'' = map (headerToPair getExpires) hs'
hs''' = ("Content-Type", charsToBs ct) : hs''
-}
httpAccept :: W.Request -> [ContentType] httpAccept :: W.Request -> [ContentType]
httpAccept = parseHttpAccept httpAccept = parseHttpAccept