scotty-0.12.1: Haskell web framework inspired by Ruby's Sinatra, using WAI and Warp

Safe Haskell | Safe-Inferred
Language | Haskell2010

Web.Scotty.Internal.Types

Synopsis

- data Options = Options {
  - verbose :: Int
  - settings :: Settings
  }
- newtype RouteOptions = RouteOptions {
  - maxRequestBodySize :: Maybe Kilobytes
  }
- type Kilobytes = Int
- type Middleware m = Application m -> Application m
- type Application m = Request -> m Response
- data ScottyState e m = ScottyState {
  - middlewares :: [Middleware]
  - routes :: [Middleware m]
  - handler :: ErrorHandler e m
  - routeOptions :: RouteOptions
  }
- addMiddleware :: Middleware -> ScottyState e m -> ScottyState e m
- addRoute :: Middleware m -> ScottyState e m -> ScottyState e m
- addHandler :: ErrorHandler e m -> ScottyState e m -> ScottyState e m
- updateMaxRequestBodySize :: RouteOptions -> ScottyState e m -> ScottyState e m
- newtype ScottyT e m a = ScottyT {
  - runS :: State (ScottyState e m) a
  }
- data ActionError e
  - = Redirect Text
  - | Next
  - | Finish
  - | ActionError Status e
- class ScottyError e where
  - stringError :: String -> e
  - showError :: e -> Text
- type ErrorHandler e m = Maybe (e -> ActionT e m ())
- data ScottyException = RequestException ByteString Status
- type Param = (Text, Text)
- type File = (Text, FileInfo ByteString)
- data ActionEnv = Env {
  - getReq :: Request
  - getParams :: [Param]
  - getBody :: IO ByteString
  - getBodyChunk :: IO ByteString
  - getFiles :: [File]
  }
- data RequestBodyState
  - = BodyUntouched
  - | BodyCached ByteString [ByteString]
  - | BodyCorrupted
- data BodyPartiallyStreamed = BodyPartiallyStreamed
- data Content
  - = ContentBuilder Builder
  - | ContentFile FilePath
  - | ContentStream StreamingBody
- data ScottyResponse = SR {
  - srStatus :: Status
  - srHeaders :: ResponseHeaders
  - srContent :: Content
  }
- newtype ActionT e m a = ActionT {
  - runAM :: ExceptT (ActionError e) (ReaderT ActionEnv (StateT ScottyResponse m)) a
  }
- data RoutePattern
  - = Capture Text
  - | Literal Text
  - | Function (Request -> Maybe [Param])

# Documentation

data Options Source #

Constructors

Options |

Fields

- 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`.

#### Instances

Instances details

Default Options Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods def :: Options Source #

newtype RouteOptions Source #

Constructors

RouteOptions |

Fields

- maxRequestBodySize :: Maybe Kilobytes

#### Instances

Instances details

Default RouteOptions Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods def :: RouteOptions Source #

type Kilobytes = Int Source #

type Middleware m = Application m -> Application m Source #

type Application m = Request -> m Response Source #

data ScottyState e m Source #

Constructors

ScottyState |

Fields

- middlewares :: [Middleware]
- routes :: [Middleware m]
- handler :: ErrorHandler e m
- routeOptions :: RouteOptions

#### Instances

Instances details

Default (ScottyState e m) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods def :: ScottyState e m Source #

addMiddleware :: Middleware -> ScottyState e m -> ScottyState e m Source #

addRoute :: Middleware m -> ScottyState e m -> ScottyState e m Source #

addHandler :: ErrorHandler e m -> ScottyState e m -> ScottyState e m Source #

updateMaxRequestBodySize :: RouteOptions -> ScottyState e m -> ScottyState e m Source #

newtype ScottyT e m a Source #

Constructors

ScottyT |

Fields

- runS :: State (ScottyState e m) a

#### Instances

Instances details

Applicative (ScottyT e m) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods pure :: a -> ScottyT e m a Source # (<*>) :: ScottyT e m (a -> b) -> ScottyT e m a -> ScottyT e m b Source # liftA2 :: (a -> b -> c) -> ScottyT e m a -> ScottyT e m b -> ScottyT e m c Source # (*>) :: ScottyT e m a -> ScottyT e m b -> ScottyT e m b Source # (<*) :: ScottyT e m a -> ScottyT e m b -> ScottyT e m a Source #
Functor (ScottyT e m) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods fmap :: (a -> b) -> ScottyT e m a -> ScottyT e m b Source # (<$) :: a -> ScottyT e m b -> ScottyT e m a Source #
Monad (ScottyT e m) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods (>>=) :: ScottyT e m a -> (a -> ScottyT e m b) -> ScottyT e m b Source # (>>) :: ScottyT e m a -> ScottyT e m b -> ScottyT e m b Source # return :: a -> ScottyT e m a Source #
Monoid a => Monoid (ScottyT e m a) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods mempty :: ScottyT e m a Source # mappend :: ScottyT e m a -> ScottyT e m a -> ScottyT e m a Source # mconcat :: [ScottyT e m a] -> ScottyT e m a Source #
Semigroup a => Semigroup (ScottyT e m a) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods (<>) :: ScottyT e m a -> ScottyT e m a -> ScottyT e m a Source # sconcat :: NonEmpty (ScottyT e m a) -> ScottyT e m a Source # stimes :: Integral b => b -> ScottyT e m a -> ScottyT e m a Source #

data ActionError e Source #

Constructors

Redirect Text |
Next |
Finish |
ActionError Status e |

#### Instances

Instances details

ScottyError e => ScottyError (ActionError e) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods stringError :: String -> ActionError e Source # showError :: ActionError e -> Text Source #
(ScottyError e, Monad m) => MonadError (ActionError e) (ActionT e m) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods throwError :: ActionError e -> ActionT e m a Source # catchError :: ActionT e m a -> (ActionError e -> ActionT e m a) -> ActionT e m a Source #

class ScottyError e where Source #

In order to use a custom exception type (aside from `Text`), you must define an instance of `ScottyError` for that type.

Methods

stringError :: String -> e Source #

showError :: e -> Text Source #

#### Instances

Instances details

ScottyError Text Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods stringError :: String -> Text Source # showError :: Text -> Text Source #
ScottyError e => ScottyError (ActionError e) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods stringError :: String -> ActionError e Source # showError :: ActionError e -> Text Source #

type ErrorHandler e m = Maybe (e -> ActionT e m ()) Source #

data ScottyException Source #

Constructors

RequestException ByteString Status |

#### Instances

Instances details

Exception ScottyException Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods toException :: ScottyException -> SomeException Source # fromException :: SomeException -> Maybe ScottyException Source # displayException :: ScottyException -> String Source #
Show ScottyException Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods showsPrec :: Int -> ScottyException -> ShowS Source # show :: ScottyException -> String Source # showList :: [ScottyException] -> ShowS Source #

type Param = (Text, Text) Source #

type File = (Text, FileInfo ByteString) Source #

data ActionEnv Source #

Constructors

Env |

Fields

- getReq :: Request
- getParams :: [Param]
- getBody :: IO ByteString
- getBodyChunk :: IO ByteString
- getFiles :: [File]

data RequestBodyState Source #

Constructors

BodyUntouched |
BodyCached ByteString [ByteString] |
BodyCorrupted |

data BodyPartiallyStreamed Source #

Constructors

BodyPartiallyStreamed |

#### Instances

Instances details

Exception BodyPartiallyStreamed Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods toException :: BodyPartiallyStreamed -> SomeException Source # fromException :: SomeException -> Maybe BodyPartiallyStreamed Source # displayException :: BodyPartiallyStreamed -> String Source #
Show BodyPartiallyStreamed Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods showsPrec :: Int -> BodyPartiallyStreamed -> ShowS Source # show :: BodyPartiallyStreamed -> String Source # showList :: [BodyPartiallyStreamed] -> ShowS Source #

data Content Source #

Constructors

ContentBuilder Builder |
ContentFile FilePath |
ContentStream StreamingBody |

data ScottyResponse Source #

Constructors

SR |

Fields

- srStatus :: Status
- srHeaders :: ResponseHeaders
- srContent :: Content

#### Instances

Instances details

Default ScottyResponse Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods def :: ScottyResponse Source #

newtype ActionT e m a Source #

Constructors

ActionT |

Fields

- runAM :: ExceptT (ActionError e) (ReaderT ActionEnv (StateT ScottyResponse m)) a

#### Instances

Instances details

(ScottyError e, MonadBaseControl b m) => MonadBaseControl b (ActionT e m) Source # |
Instance details Defined in Web.Scotty.Internal.Types Associated Types type StM (ActionT e m) a Source # Methods liftBaseWith :: (RunInBase (ActionT e m) b -> b a) -> ActionT e m a Source # restoreM :: StM (ActionT e m) a -> ActionT e m a Source #
(MonadReader r m, ScottyError e) => MonadReader r (ActionT e m) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods ask :: ActionT e m r Source # local :: (r -> r) -> ActionT e m a -> ActionT e m a Source # reader :: (r -> a) -> ActionT e m a Source #
(MonadState s m, ScottyError e) => MonadState s (ActionT e m) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods get :: ActionT e m s Source # put :: s -> ActionT e m () Source # state :: (s -> (a, s)) -> ActionT e m a Source #
(MonadBase b m, ScottyError e) => MonadBase b (ActionT e m) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods liftBase :: b α -> ActionT e m α Source #
ScottyError e => MonadTransControl (ActionT e) Source # |
Instance details Defined in Web.Scotty.Internal.Types Associated Types type StT (ActionT e) a Source # Methods liftWith :: Monad m => (Run (ActionT e) -> m a) -> ActionT e m a Source # restoreT :: Monad m => m (StT (ActionT e) a) -> ActionT e m a Source #
ScottyError e => MonadTrans (ActionT e) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods lift :: Monad m => m a -> ActionT e m a Source #
(ScottyError e, Monad m) => MonadError (ActionError e) (ActionT e m) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods throwError :: ActionError e -> ActionT e m a Source # catchError :: ActionT e m a -> (ActionError e -> ActionT e m a) -> ActionT e m a Source #
(Monad m, ScottyError e) => MonadFail (ActionT e m) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods fail :: String -> ActionT e m a Source #
(ScottyError e, MonadIO m) => MonadIO (ActionT e m) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods liftIO :: IO a -> ActionT e m a Source #
(Monad m, ScottyError e) => Alternative (ActionT e m) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods empty :: ActionT e m a Source # (<|>) :: ActionT e m a -> ActionT e m a -> ActionT e m a Source # some :: ActionT e m a -> ActionT e m [a] Source # many :: ActionT e m a -> ActionT e m [a] Source #
Monad m => Applicative (ActionT e m) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods pure :: a -> ActionT e m a Source # (<*>) :: ActionT e m (a -> b) -> ActionT e m a -> ActionT e m b Source # liftA2 :: (a -> b -> c) -> ActionT e m a -> ActionT e m b -> ActionT e m c Source # (*>) :: ActionT e m a -> ActionT e m b -> ActionT e m b Source # (<*) :: ActionT e m a -> ActionT e m b -> ActionT e m a Source #
Functor m => Functor (ActionT e m) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods fmap :: (a -> b) -> ActionT e m a -> ActionT e m b Source # (<$) :: a -> ActionT e m b -> ActionT e m a Source #
(Monad m, ScottyError e) => Monad (ActionT e m) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods (>>=) :: ActionT e m a -> (a -> ActionT e m b) -> ActionT e m b Source # (>>) :: ActionT e m a -> ActionT e m b -> ActionT e m b Source # return :: a -> ActionT e m a Source #
(Monad m, ScottyError e) => MonadPlus (ActionT e m) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods mzero :: ActionT e m a Source # mplus :: ActionT e m a -> ActionT e m a -> ActionT e m a Source #
(MonadCatch m, ScottyError e) => MonadCatch (ActionT e m) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods catch :: Exception e0 => ActionT e m a -> (e0 -> ActionT e m a) -> ActionT e m a Source #
(MonadThrow m, ScottyError e) => MonadThrow (ActionT e m) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods throwM :: Exception e0 => e0 -> ActionT e m a Source #
(Monad m, ScottyError e, Monoid a) => Monoid (ActionT e m a) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods mempty :: ActionT e m a Source # mappend :: ActionT e m a -> ActionT e m a -> ActionT e m a Source # mconcat :: [ActionT e m a] -> ActionT e m a Source #
(Monad m, Semigroup a) => Semigroup (ActionT e m a) Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods (<>) :: ActionT e m a -> ActionT e m a -> ActionT e m a Source # sconcat :: NonEmpty (ActionT e m a) -> ActionT e m a Source # stimes :: Integral b => b -> ActionT e m a -> ActionT e m a Source #
type StT (ActionT e) a Source # |
Instance details Defined in Web.Scotty.Internal.Types type StT (ActionT e) a = StT (StateT ScottyResponse) (StT (ReaderT ActionEnv) (StT (ExceptT (ActionError e)) a))
type StM (ActionT e m) a Source # |
Instance details Defined in Web.Scotty.Internal.Types type StM (ActionT e m) a = ComposeSt (ActionT e) m a

data RoutePattern Source #

Constructors

Capture Text |
Literal Text |
Function (Request -> Maybe [Param]) |

#### Instances

Instances details

IsString RoutePattern Source # |
Instance details Defined in Web.Scotty.Internal.Types Methods fromString :: String -> RoutePattern Source #