Skip to content

Commit

Permalink
keep data-default-class
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Zocca committed Oct 2, 2023
1 parent 145b610 commit fdd70a7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion Web/Scotty/Internal/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import Control.Monad.Trans.Except

import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy.Char8 as LBS8 (ByteString)
-- import Data.Default.Class (Default, def)
import Data.Default.Class (Default, def)
import Data.String (IsString(..))
import Data.Text.Lazy (Text, pack)
import Data.Typeable (Typeable)
Expand Down Expand Up @@ -65,12 +65,18 @@ data Options = Options { verbose :: Int -- ^ 0 = silent, 1(def) = startup banner
-- servers using `setFdCacheDuration`.
}

instance Default Options where
def = defaultOptions

defaultOptions :: Options
defaultOptions = Options 1 defaultSettings

newtype RouteOptions = RouteOptions { maxRequestBodySize :: Maybe Kilobytes -- max allowed request size in KB
}

instance Default RouteOptions where
def = defaultRouteOptions

defaultRouteOptions :: RouteOptions
defaultRouteOptions = RouteOptions Nothing

Expand Down Expand Up @@ -101,6 +107,9 @@ data ScottyState m =
, routeOptions :: RouteOptions
}

instance Default (ScottyState m) where
def = defaultScottyState

defaultScottyState :: ScottyState m
defaultScottyState = ScottyState [] [] Nothing defaultRouteOptions

Expand Down Expand Up @@ -197,6 +206,9 @@ setHeaderWith f sr = sr { srHeaders = f (srHeaders sr) }
setStatus :: Status -> ScottyResponse -> ScottyResponse
setStatus s sr = sr { srStatus = s }

instance Default ScottyResponse where
def = defaultScottyResponse

-- | The default response has code 200 OK and empty body
defaultScottyResponse :: ScottyResponse
defaultScottyResponse = SR status200 [] (ContentBuilder mempty)
Expand Down
1 change: 0 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Breaking:
* (#310) Introduce `unliftio-core` as a dependency, and base exception handling on methods copied from `unliftio` e.g. `catch`.
* (#310) Clarify the exception handling mechanism of ActionT, ScottyT. `raise` and `rescue` change signature to use proper `Exception` types rather than strings.
* (#310) All ActionT methods (`text`, `html` etc.) have now a MonadIO constraint on the base monad rather than Monad because the response is in a TVar inside ActionEnv. `rescue` has a MonadUnliftIO constraint. The Alternative instance of ActionT also is based on MonadUnliftIO because `<|>` is implemented in terms of `catch`.
* Get rid of data-default-class (#316)

## 0.12.1 [2022.11.17]
* Fix CPP bug that prevented tests from building on Windows.
Expand Down
1 change: 1 addition & 0 deletions scotty.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Library
bytestring >= 0.10.0.2 && < 0.12,
case-insensitive >= 1.0.0.1 && < 1.3,
cookie >= 0.4,
data-default-class >= 0.1,
exceptions >= 0.7 && < 0.11,
http-types >= 0.9.1 && < 0.13,
monad-control >= 1.0.0.3 && < 1.1,
Expand Down

0 comments on commit fdd70a7

Please sign in to comment.