Skip to content

Commit

Permalink
bench builds as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Zocca committed Oct 2, 2023
1 parent dc9d904 commit 511c8eb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Web/Scotty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module Web.Scotty
, Param, Trans.Parsable(..), Trans.readEither
-- * Types
, ScottyM, ActionM, RoutePattern, File, Kilobytes, Handler(..)
, ScottyState, defaultScottyState
) where

-- With the exception of this, everything else better just import types.
Expand All @@ -51,7 +52,7 @@ import Network.Socket (Socket)
import Network.Wai (Application, Middleware, Request, StreamingBody)
import Network.Wai.Handler.Warp (Port)

import Web.Scotty.Internal.Types (ScottyT, ActionT, ErrorHandler, Param, RoutePattern, Options, defaultOptions, File, Kilobytes)
import Web.Scotty.Internal.Types (ScottyT, ActionT, ErrorHandler, Param, RoutePattern, Options, defaultOptions, File, Kilobytes, ScottyState, defaultScottyState)
import Web.Scotty.Exceptions (Handler(..))

type ScottyM = ScottyT IO
Expand Down
5 changes: 3 additions & 2 deletions Web/Scotty/Trans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module Web.Scotty.Trans
, RoutePattern, File, Kilobytes, ErrorHandler, Handler(..)
-- * Monad Transformers
, ScottyT, ActionT
, ScottyState, defaultScottyState
) where

import Blaze.ByteString.Builder (fromByteString)
Expand All @@ -58,7 +59,7 @@ import Network.Wai.Handler.Warp (Port, runSettings, runSettingsSocket, setPort,

import Web.Scotty.Action
import Web.Scotty.Route
import Web.Scotty.Internal.Types (ActionT(..), ScottyT(..), defaultScottyState, Application, RoutePattern, Options(..), defaultOptions, RouteOptions(..), defaultRouteOptions, ErrorHandler, Kilobytes, File, addMiddleware, setHandler, updateMaxRequestBodySize, routes, middlewares, ScottyException(..))
import Web.Scotty.Internal.Types (ActionT(..), ScottyT(..), defaultScottyState, Application, RoutePattern, Options(..), defaultOptions, RouteOptions(..), defaultRouteOptions, ErrorHandler, Kilobytes, File, addMiddleware, setHandler, updateMaxRequestBodySize, routes, middlewares, ScottyException(..), ScottyState, defaultScottyState)
import Web.Scotty.Util (socketDescription)
import Web.Scotty.Body (newBodyInfo)
import Web.Scotty.Exceptions (Handler(..), catches)
Expand Down Expand Up @@ -129,7 +130,7 @@ defaultHandler f = ScottyT $ modify $ setHandler $ Just f
scottyExceptionHandler :: MonadIO m => Handler m W.Response
scottyExceptionHandler = Handler $ \case
RequestException ebody s -> do
return $ W.responseBuilder s [] (fromByteString ebody)
return $ W.responseBuilder s [("Content-Type", "text/plain")] (fromByteString ebody)


-- | Use given middleware. Middleware is nested such that the first declared
Expand Down
8 changes: 3 additions & 5 deletions bench/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
module Main (main) where

import Control.Monad
import Data.Default.Class (def)
import Data.Functor.Identity
import Data.Text (Text)
import Lucid.Base
import Lucid.Html5
import Web.Scotty
Expand All @@ -25,9 +23,9 @@ main = do
setColumns [Case,Allocated,GCs,Live,Check,Max,MaxOS]
setFormat Markdown
io "ScottyM Strict" BL.putStr
(SS.evalState (runS $ renderBST htmlScotty) def)
(SS.evalState (runS $ renderBST htmlScotty) defaultScottyState)
io "ScottyM Lazy" BL.putStr
(SL.evalState (runScottyLazy $ renderBST htmlScottyLazy) def)
(SL.evalState (runScottyLazy $ renderBST htmlScottyLazy) defaultScottyState)
io "Identity" BL.putStr
(runIdentity $ renderBST htmlIdentity)

Expand All @@ -49,6 +47,6 @@ htmlScottyLazy = htmlTest
{-# noinline htmlScottyLazy #-}

newtype ScottyLazy a = ScottyLazy
{ runScottyLazy:: SL.State (ScottyState Text IO) a }
{ runScottyLazy:: SL.State (ScottyState IO) a }
deriving (Functor,Applicative,Monad)

0 comments on commit 511c8eb

Please sign in to comment.