scotty 0.7.0 → 0.7.1
raw patch · 5 files changed
+35/−6 lines, 5 files
Files
- Web/Scotty.hs +9/−0
- Web/Scotty/Trans.hs +12/−3
- Web/Scotty/Types.hs +8/−2
- changelog.md +5/−0
- scotty.cabal +1/−1
Web/Scotty.hs view
@@ -1,6 +1,10 @@ {-# LANGUAGE OverloadedStrings, RankNTypes #-} -- | It should be noted that most of the code snippets below depend on the -- OverloadedStrings language pragma.+--+-- Scotty is set up by default for development mode. For production servers,+-- you will likely want to modify 'Trans.settings' and the 'defaultHandler'. See+-- the comments on each of these functions for more information. module Web.Scotty ( -- * scotty-to-WAI scotty, scottyApp, scottyOpts, Options(..)@@ -65,6 +69,11 @@ -- -- Uncaught exceptions normally become 500 responses. -- You can use this to selectively override that behavior.+--+-- Note: IO exceptions are lifted into Scotty exceptions by default.+-- This has security implications, so you probably want to provide your+-- own defaultHandler in production which does not send out the error +-- strings as 500 responses. defaultHandler :: (Text -> ActionM ()) -> ScottyM () defaultHandler = Trans.defaultHandler
Web/Scotty/Trans.hs view
@@ -5,6 +5,10 @@ -- The functions in this module allow an arbitrary monad to be embedded -- in Scotty's monad transformer stack in order that Scotty be combined -- with other DSLs.+--+-- Scotty is set up by default for development mode. For production servers,+-- you will likely want to modify 'settings' and the 'defaultHandler'. See+-- the comments on each of these functions for more information. module Web.Scotty.Trans ( -- * scotty-to-WAI scottyT, scottyAppT, scottyOptsT, Options(..)@@ -53,7 +57,7 @@ import qualified Web.Scotty.Types as Scotty -- | Run a scotty application using the warp server.--- NB: 'scotty p' === 'scottyT p id id'+-- NB: scotty p === scottyT p id id scottyT :: (Monad m, MonadIO n) => Port -> (forall a. m a -> n a) -- ^ Run monad 'm' into monad 'n', called once at 'ScottyT' level.@@ -63,7 +67,7 @@ scottyT p = scottyOptsT $ def { settings = setPort p (settings def) } -- | Run a scotty application using the warp server, passing extra options.--- NB: 'scottyOpts opts' === 'scottyOptsT opts id id'+-- NB: scottyOpts opts === scottyOptsT opts id id scottyOptsT :: (Monad m, MonadIO n) => Options -> (forall a. m a -> n a) -- ^ Run monad 'm' into monad 'n', called once at 'ScottyT' level.@@ -77,7 +81,7 @@ -- | Turn a scotty application into a WAI 'Application', which can be -- run with any WAI handler.--- NB: 'scottyApp' === 'scottyAppT id id'+-- NB: scottyApp === scottyAppT id id scottyAppT :: (Monad m, Monad n) => (forall a. m a -> n a) -- ^ Run monad 'm' into monad 'n', called once at 'ScottyT' level. -> (m Response -> IO Response) -- ^ Run monad 'm' into 'IO', called at each action.@@ -96,6 +100,11 @@ -- -- Uncaught exceptions normally become 500 responses. -- You can use this to selectively override that behavior.+--+-- Note: IO exceptions are lifted into 'ScottyError's by 'stringError'.+-- This has security implications, so you probably want to provide your+-- own defaultHandler in production which does not send out the error +-- strings as 500 responses. defaultHandler :: Monad m => (e -> ActionT e m ()) -> ScottyT e m () defaultHandler f = ScottyT $ modify $ addHandler $ Just f
Web/Scotty/Types.hs view
@@ -20,16 +20,22 @@ import Network.Wai hiding (Middleware, Application) import qualified Network.Wai as Wai-import Network.Wai.Handler.Warp (Settings, defaultSettings)+import Network.Wai.Handler.Warp (Settings, defaultSettings, setFdCacheDuration) import Network.Wai.Parse (FileInfo) --------------------- Options ----------------------- data Options = Options { verbose :: Int -- ^ 0 = silent, 1(def) = startup banner , settings :: Settings -- ^ Warp 'Settings'+ -- Note: to work around an issue in warp,+ -- the default FD cache duration is set to 0+ -- so changes to static files are always picked+ -- up. This likely has performance implications,+ -- so you may want to modify this for production+ -- servers using `setFdCacheDuration`. } instance Default Options where- def = Options 1 defaultSettings+ def = Options 1 (setFdCacheDuration 0 defaultSettings) ----- Transformer Aware Applications/Middleware ----- type Middleware m = Application m -> Application m
changelog.md view
@@ -1,3 +1,8 @@+## 0.7.1++* Default warp settings now use `setFdCacheDuration 0` to work around a warp+ issue where file changes are not getting picked up.+ ## 0.7.0 * Renamed `reqHeader` to `header`. Added `headers` function to get all headers.
scotty.cabal view
@@ -1,5 +1,5 @@ Name: scotty-Version: 0.7.0+Version: 0.7.1 Synopsis: Haskell web framework inspired by Ruby's Sinatra, using WAI and Warp Homepage: https://github.com/scotty-web/scotty Bug-reports: https://github.com/scotty-web/scotty/issues