gzip changes
This commit is contained in:
parent
0e1feefa09
commit
858b4cc4c2
@ -149,7 +149,7 @@ mkYesodGeneral name args clazzes isSub resS = do
|
|||||||
toWaiApp :: ( Yesod master
|
toWaiApp :: ( Yesod master
|
||||||
, YesodDispatch master master
|
, YesodDispatch master master
|
||||||
) => master -> IO W.Application
|
) => 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
|
-- | Convert the given argument into a WAI application, executable with any WAI
|
||||||
-- handler. This differs from 'toWaiApp' in that it uses no middlewares.
|
-- handler. This differs from 'toWaiApp' in that it uses no middlewares.
|
||||||
|
|||||||
@ -76,6 +76,7 @@ import Text.Blaze (preEscapedLazyText)
|
|||||||
import Data.Aeson (Value (Array, String))
|
import Data.Aeson (Value (Array, String))
|
||||||
import Data.Aeson.Encode (encode)
|
import Data.Aeson.Encode (encode)
|
||||||
import qualified Data.Vector as Vector
|
import qualified Data.Vector as Vector
|
||||||
|
import Network.Wai.Middleware.Gzip (GzipSettings, def)
|
||||||
|
|
||||||
-- mega repo can't access this
|
-- mega repo can't access this
|
||||||
#ifndef MEGA
|
#ifndef MEGA
|
||||||
@ -275,9 +276,9 @@ class RenderRoute a => Yesod a where
|
|||||||
formatLogMessage loc level msg >>=
|
formatLogMessage loc level msg >>=
|
||||||
Data.Text.Lazy.IO.putStrLn
|
Data.Text.Lazy.IO.putStrLn
|
||||||
|
|
||||||
-- | Apply gzip compression to files. Default is false.
|
-- | GZIP settings.
|
||||||
gzipCompressFiles :: a -> Bool
|
gzipSettings :: a -> GzipSettings
|
||||||
gzipCompressFiles _ = False
|
gzipSettings _ = def
|
||||||
|
|
||||||
-- | Location of yepnope.js, if any. If one is provided, then all
|
-- | Location of yepnope.js, if any. If one is provided, then all
|
||||||
-- Javascript files will be loaded asynchronously.
|
-- Javascript files will be loaded asynchronously.
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import Network.Wai (Application)
|
|||||||
import Network.Wai.Handler.Warp
|
import Network.Wai.Handler.Warp
|
||||||
(runSettings, defaultSettings, settingsPort, settingsHost)
|
(runSettings, defaultSettings, settingsPort, settingsHost)
|
||||||
import System.Directory (doesDirectoryExist, removeDirectoryRecursive)
|
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.Autohead (autohead)
|
||||||
import Network.Wai.Middleware.Jsonp (jsonp)
|
import Network.Wai.Middleware.Jsonp (jsonp)
|
||||||
import Control.Monad (when)
|
import Control.Monad (when)
|
||||||
@ -79,7 +79,7 @@ defaultRunner f h = do
|
|||||||
takeMVar flag
|
takeMVar flag
|
||||||
#endif
|
#endif
|
||||||
where
|
where
|
||||||
middlewares = gzip' gset . jsonp . autohead
|
middlewares = gzip gset . jsonp . autohead
|
||||||
|
|
||||||
gset = def { gzipFiles = GzipCacheFolder staticCache }
|
gset = def { gzipFiles = GzipCacheFolder staticCache }
|
||||||
staticCache = ".static-cache"
|
staticCache = ".static-cache"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user