From 858b4cc4c28a5ca053069dfdf483d2149d16aebf Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Fri, 6 Jan 2012 14:51:44 +0200 Subject: [PATCH] gzip changes --- yesod-core/Yesod/Dispatch.hs | 2 +- yesod-core/Yesod/Internal/Core.hs | 7 ++++--- yesod-default/Yesod/Default/Main.hs | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/yesod-core/Yesod/Dispatch.hs b/yesod-core/Yesod/Dispatch.hs index e4d81810..e9ce2811 100644 --- a/yesod-core/Yesod/Dispatch.hs +++ b/yesod-core/Yesod/Dispatch.hs @@ -149,7 +149,7 @@ mkYesodGeneral name args clazzes isSub resS = do toWaiApp :: ( Yesod master , YesodDispatch master master ) => master -> IO W.Application -toWaiApp y = gzip (gzipCompressFiles y) . autohead <$> toWaiAppPlain y +toWaiApp y = gzip (gzipSettings y) . autohead <$> toWaiAppPlain y -- | Convert the given argument into a WAI application, executable with any WAI -- handler. This differs from 'toWaiApp' in that it uses no middlewares. diff --git a/yesod-core/Yesod/Internal/Core.hs b/yesod-core/Yesod/Internal/Core.hs index 17b17085..1db7854a 100644 --- a/yesod-core/Yesod/Internal/Core.hs +++ b/yesod-core/Yesod/Internal/Core.hs @@ -76,6 +76,7 @@ import Text.Blaze (preEscapedLazyText) import Data.Aeson (Value (Array, String)) import Data.Aeson.Encode (encode) import qualified Data.Vector as Vector +import Network.Wai.Middleware.Gzip (GzipSettings, def) -- mega repo can't access this #ifndef MEGA @@ -275,9 +276,9 @@ class RenderRoute a => Yesod a where formatLogMessage loc level msg >>= Data.Text.Lazy.IO.putStrLn - -- | Apply gzip compression to files. Default is false. - gzipCompressFiles :: a -> Bool - gzipCompressFiles _ = False + -- | GZIP settings. + gzipSettings :: a -> GzipSettings + gzipSettings _ = def -- | Location of yepnope.js, if any. If one is provided, then all -- Javascript files will be loaded asynchronously. diff --git a/yesod-default/Yesod/Default/Main.hs b/yesod-default/Yesod/Default/Main.hs index 20221cbf..a7feb1cf 100644 --- a/yesod-default/Yesod/Default/Main.hs +++ b/yesod-default/Yesod/Default/Main.hs @@ -14,7 +14,7 @@ import Network.Wai (Application) import Network.Wai.Handler.Warp (runSettings, defaultSettings, settingsPort, settingsHost) import System.Directory (doesDirectoryExist, removeDirectoryRecursive) -import Network.Wai.Middleware.Gzip (gzip', GzipFiles (GzipCacheFolder), gzipFiles, def) +import Network.Wai.Middleware.Gzip (gzip, GzipFiles (GzipCacheFolder), gzipFiles, def) import Network.Wai.Middleware.Autohead (autohead) import Network.Wai.Middleware.Jsonp (jsonp) import Control.Monad (when) @@ -79,7 +79,7 @@ defaultRunner f h = do takeMVar flag #endif where - middlewares = gzip' gset . jsonp . autohead + middlewares = gzip gset . jsonp . autohead gset = def { gzipFiles = GzipCacheFolder staticCache } staticCache = ".static-cache"