Added yesodMiddleware method
This commit is contained in:
parent
6a7102f44e
commit
d37b0634a5
@ -372,6 +372,17 @@ $doctype 5
|
|||||||
shouldLog :: a -> LogSource -> LogLevel -> Bool
|
shouldLog :: a -> LogSource -> LogLevel -> Bool
|
||||||
shouldLog a _ level = level >= logLevel a
|
shouldLog a _ level = level >= logLevel a
|
||||||
|
|
||||||
|
-- | A Yesod middleware, which will wrap every handler function. This
|
||||||
|
-- allows you to run code before and after a normal handler.
|
||||||
|
--
|
||||||
|
-- Default: Adds the response header \"Vary: Accept, Accept-Language\".
|
||||||
|
--
|
||||||
|
-- Since: 1.1.6
|
||||||
|
yesodMiddleware :: GHandler sub a res -> GHandler sub a res
|
||||||
|
yesodMiddleware handler = do
|
||||||
|
setHeader "Vary" "Accept, Accept-Language"
|
||||||
|
handler
|
||||||
|
|
||||||
{-# DEPRECATED messageLogger "Please use messageLoggerSource (since yesod-core 1.1.2)" #-}
|
{-# DEPRECATED messageLogger "Please use messageLoggerSource (since yesod-core 1.1.2)" #-}
|
||||||
|
|
||||||
formatLogMessage :: IO ZonedDate
|
formatLogMessage :: IO ZonedDate
|
||||||
@ -419,7 +430,7 @@ defaultYesodRunner :: Yesod master
|
|||||||
-> (Route sub -> Route master)
|
-> (Route sub -> Route master)
|
||||||
-> Maybe (SessionBackend master)
|
-> Maybe (SessionBackend master)
|
||||||
-> W.Application
|
-> W.Application
|
||||||
defaultYesodRunner logger handler master sub murl toMasterRoute msb req
|
defaultYesodRunner logger handler' master sub murl toMasterRoute msb req
|
||||||
| maximumContentLength master (fmap toMasterRoute murl) < len =
|
| maximumContentLength master (fmap toMasterRoute murl) < len =
|
||||||
return $ W.responseLBS
|
return $ W.responseLBS
|
||||||
(H.Status 413 "Too Large")
|
(H.Status 413 "Too Large")
|
||||||
@ -469,6 +480,7 @@ defaultYesodRunner logger handler master sub murl toMasterRoute msb req
|
|||||||
case reads $ S8.unpack s of
|
case reads $ S8.unpack s of
|
||||||
[] -> Nothing
|
[] -> Nothing
|
||||||
(x, _):_ -> Just x
|
(x, _):_ -> Just x
|
||||||
|
handler = yesodMiddleware handler'
|
||||||
|
|
||||||
data AuthResult = Authorized | AuthenticationRequired | Unauthorized Text
|
data AuthResult = Authorized | AuthenticationRequired | Unauthorized Text
|
||||||
deriving (Eq, Show, Read)
|
deriving (Eq, Show, Read)
|
||||||
|
|||||||
@ -131,3 +131,4 @@ case_jshead = runner $ do
|
|||||||
{ pathInfo = ["jshead"]
|
{ pathInfo = ["jshead"]
|
||||||
}
|
}
|
||||||
assertBody "<!DOCTYPE html>\n<html><head><title></title><script>alert(\"hello\");</script></head><body></body></html>" res
|
assertBody "<!DOCTYPE html>\n<html><head><title></title><script>alert(\"hello\");</script></head><body></body></html>" res
|
||||||
|
assertHeader "Vary" "Accept, Accept-Language" res
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod-core
|
name: yesod-core
|
||||||
version: 1.1.5
|
version: 1.1.6
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman <michael@snoyman.com>
|
author: Michael Snoyman <michael@snoyman.com>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user