yesod-default uses new GzipCacheFolder
This commit is contained in:
parent
22bf832cbb
commit
325d912be3
@ -13,6 +13,11 @@ import Yesod.Logger (Logger, makeLogger, logString, logLazyText, flushLogger)
|
|||||||
import Network.Wai (Application)
|
import Network.Wai (Application)
|
||||||
import Network.Wai.Handler.Warp (run)
|
import Network.Wai.Handler.Warp (run)
|
||||||
import Network.Wai.Middleware.Debug (debugHandle)
|
import Network.Wai.Middleware.Debug (debugHandle)
|
||||||
|
import System.Directory (doesDirectoryExist, removeDirectoryRecursive)
|
||||||
|
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)
|
||||||
|
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
import qualified System.Posix.Signals as Signal
|
import qualified System.Posix.Signals as Signal
|
||||||
@ -55,19 +60,25 @@ defaultRunner :: (YesodDispatch y y, Yesod y)
|
|||||||
=> (Application -> IO a)
|
=> (Application -> IO a)
|
||||||
-> y -- ^ your foundation type
|
-> y -- ^ your foundation type
|
||||||
-> IO ()
|
-> IO ()
|
||||||
defaultRunner f h =
|
defaultRunner f h = do
|
||||||
|
-- clear the .static-cache so we don't have stale content
|
||||||
|
exists <- doesDirectoryExist staticCache
|
||||||
|
when exists $ removeDirectoryRecursive staticCache
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
toWaiApp h >>= f >> return ()
|
toWaiAppPlain h >>= f . middlewares >> return ()
|
||||||
#else
|
#else
|
||||||
do
|
tid <- forkIO $ toWaiAppPlain h >>= f . middlewares >> return ()
|
||||||
tid <- forkIO $ toWaiApp h >>= f >> return ()
|
flag <- newEmptyMVar
|
||||||
flag <- newEmptyMVar
|
_ <- Signal.installHandler Signal.sigINT (Signal.CatchOnce $ do
|
||||||
_ <- Signal.installHandler Signal.sigINT (Signal.CatchOnce $ do
|
putStrLn "Caught an interrupt"
|
||||||
putStrLn "Caught an interrupt"
|
killThread tid
|
||||||
killThread tid
|
putMVar flag ()) Nothing
|
||||||
putMVar flag ()) Nothing
|
takeMVar flag
|
||||||
takeMVar flag
|
|
||||||
#endif
|
#endif
|
||||||
|
where
|
||||||
|
middlewares = gzip' gset . jsonp . autohead
|
||||||
|
gset = def { gzipFiles = GzipCacheFolder staticCache }
|
||||||
|
staticCache = ".static-cache"
|
||||||
|
|
||||||
-- | Run your development app using the provided @'DefaultEnv'@ type
|
-- | Run your development app using the provided @'DefaultEnv'@ type
|
||||||
--
|
--
|
||||||
|
|||||||
@ -22,7 +22,7 @@ library
|
|||||||
, cmdargs >= 0.8 && < 0.9
|
, cmdargs >= 0.8 && < 0.9
|
||||||
, warp >= 0.4 && < 0.5
|
, warp >= 0.4 && < 0.5
|
||||||
, wai >= 0.4 && < 0.5
|
, wai >= 0.4 && < 0.5
|
||||||
, wai-extra >= 0.4 && < 0.5
|
, wai-extra >= 0.4.4 && < 0.5
|
||||||
, bytestring >= 0.9 && < 0.10
|
, bytestring >= 0.9 && < 0.10
|
||||||
, transformers >= 0.2 && < 0.3
|
, transformers >= 0.2 && < 0.3
|
||||||
, text >= 0.9 && < 1.0
|
, text >= 0.9 && < 1.0
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user