Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Web.Scotty.Internal.Types
Synopsis
- data Options = Options {}
- defaultOptions :: Options
- newtype RouteOptions = RouteOptions {
- maxRequestBodySize :: Maybe Kilobytes
- defaultRouteOptions :: RouteOptions
- type Kilobytes = Int
- type Middleware m = Application m -> Application m
- type Application m = Request -> m Response
- data BodyChunkBuffer = BodyChunkBuffer {
- hasFinishedReadingChunks :: Bool
- chunksReadSoFar :: [ByteString]
- data BodyInfo = BodyInfo {
- bodyInfoReadProgress :: MVar Int
- bodyInfoChunkBuffer :: MVar BodyChunkBuffer
- bodyInfoDirectChunkRead :: IO ByteString
- data ScottyState m = ScottyState {
- middlewares :: [Middleware]
- routes :: [BodyInfo -> Middleware m]
- handler :: Maybe (ErrorHandler m)
- routeOptions :: RouteOptions
- defaultScottyState :: ScottyState m
- addMiddleware :: Middleware -> ScottyState m -> ScottyState m
- addRoute :: (BodyInfo -> Middleware m) -> ScottyState m -> ScottyState m
- setHandler :: Maybe (ErrorHandler m) -> ScottyState m -> ScottyState m
- updateMaxRequestBodySize :: RouteOptions -> ScottyState m -> ScottyState m
- newtype ScottyT m a = ScottyT {
- runS :: State (ScottyState m) a
- data ActionError
- = AERedirect Text
- | AENext
- | AEFinish
- tryNext :: MonadUnliftIO m => m a -> m Bool
- data StatusError = StatusError Status Text
- type ErrorHandler m = Handler (ActionT m) ()
- data ScottyException = RequestException ByteString Status
- type Param = (Text, Text)
- type File = (Text, FileInfo ByteString)
- data ActionEnv = Env {
- envReq :: Request
- envCaptureParams :: [Param]
- envFormParams :: [Param]
- envQueryParams :: [Param]
- envBody :: IO ByteString
- envBodyChunk :: IO ByteString
- envFiles :: [File]
- envResponse :: TVar ScottyResponse
- getResponse :: MonadIO m => ActionEnv -> m ScottyResponse
- modifyResponse :: MonadIO m => (ScottyResponse -> ScottyResponse) -> ActionT m ()
- data BodyPartiallyStreamed = BodyPartiallyStreamed
- data Content
- = ContentBuilder Builder
- | ContentFile FilePath
- | ContentStream StreamingBody
- | ContentResponse Response
- data ScottyResponse = SR {}
- setContent :: Content -> ScottyResponse -> ScottyResponse
- setHeaderWith :: ([(HeaderName, ByteString)] -> [(HeaderName, ByteString)]) -> ScottyResponse -> ScottyResponse
- setStatus :: Status -> ScottyResponse -> ScottyResponse
- defaultScottyResponse :: ScottyResponse
- newtype ActionT m a = ActionT {}
- tryAnyStatus :: MonadUnliftIO m => m a -> m Bool
- data RoutePattern
Documentation
Constructors
Options | |
Fields
|
newtype RouteOptions Source #
Constructors
RouteOptions | |
Fields
|
Instances
Default RouteOptions Source # | |
Defined in Web.Scotty.Internal.Types Methods def :: RouteOptions |
type Middleware m = Application m -> Application m Source #
type Application m = Request -> m Response Source #
data BodyChunkBuffer Source #
Constructors
BodyChunkBuffer | |
Fields
|
The key part of having two MVars is that we can "clone" the BodyInfo to create a copy where the index is reset to 0, but the chunk cache is the same. Passing a cloned BodyInfo into each matched route allows them each to start from the first chunk if they call bodyReader.
Introduced in (#308)
Constructors
BodyInfo | |
Fields
|
data ScottyState m Source #
Constructors
ScottyState | |
Fields
|
Instances
Default (ScottyState m) Source # | |
Defined in Web.Scotty.Internal.Types Methods def :: ScottyState m |
addMiddleware :: Middleware -> ScottyState m -> ScottyState m Source #
addRoute :: (BodyInfo -> Middleware m) -> ScottyState m -> ScottyState m Source #
setHandler :: Maybe (ErrorHandler m) -> ScottyState m -> ScottyState m Source #
updateMaxRequestBodySize :: RouteOptions -> ScottyState m -> ScottyState m Source #
Constructors
ScottyT | |
Fields
|
data ActionError Source #
Internal exception mechanism used to modify the request processing flow.
The exception constructor is not exposed to the user and all exceptions of this type are caught
and processed within the runAction
function.
Constructors
AERedirect Text | Redirect |
AENext | Stop processing this route and skip to the next one |
AEFinish | Stop processing the request |
Instances
Exception ActionError Source # | |
Defined in Web.Scotty.Internal.Types Methods toException :: ActionError -> SomeException fromException :: SomeException -> Maybe ActionError displayException :: ActionError -> String | |
Show ActionError Source # | |
Defined in Web.Scotty.Internal.Types Methods showsPrec :: Int -> ActionError -> ShowS show :: ActionError -> String showList :: [ActionError] -> ShowS |
data StatusError Source #
E.g. when a parameter is not found in a query string (400 Bad Request) or when parsing a JSON body fails (422 Unprocessable Entity)
Constructors
StatusError Status Text |
Instances
Exception StatusError Source # | |
Defined in Web.Scotty.Internal.Types Methods toException :: StatusError -> SomeException fromException :: SomeException -> Maybe StatusError displayException :: StatusError -> String | |
Show StatusError Source # | |
Defined in Web.Scotty.Internal.Types Methods showsPrec :: Int -> StatusError -> ShowS show :: StatusError -> String showList :: [StatusError] -> ShowS | |
MonadUnliftIO m => MonadError StatusError (ActionT m) Source # | Models the invariant that only |
Defined in Web.Scotty.Internal.Types Methods throwError :: StatusError -> ActionT m a catchError :: ActionT m a -> (StatusError -> ActionT m a) -> ActionT m a |
data ScottyException Source #
Thrown e.g. when a request is too large
Constructors
RequestException ByteString Status |
Instances
Exception ScottyException Source # | |
Defined in Web.Scotty.Internal.Types Methods toException :: ScottyException -> SomeException fromException :: SomeException -> Maybe ScottyException displayException :: ScottyException -> String | |
Show ScottyException Source # | |
Defined in Web.Scotty.Internal.Types Methods showsPrec :: Int -> ScottyException -> ShowS show :: ScottyException -> String showList :: [ScottyException] -> ShowS |
Constructors
Env | |
Fields
|
getResponse :: MonadIO m => ActionEnv -> m ScottyResponse Source #
modifyResponse :: MonadIO m => (ScottyResponse -> ScottyResponse) -> ActionT m () Source #
data BodyPartiallyStreamed Source #
Constructors
BodyPartiallyStreamed |
Instances
Exception BodyPartiallyStreamed Source # | |
Defined in Web.Scotty.Internal.Types Methods toException :: BodyPartiallyStreamed -> SomeException fromException :: SomeException -> Maybe BodyPartiallyStreamed displayException :: BodyPartiallyStreamed -> String | |
Show BodyPartiallyStreamed Source # | |
Defined in Web.Scotty.Internal.Types Methods showsPrec :: Int -> BodyPartiallyStreamed -> ShowS show :: BodyPartiallyStreamed -> String showList :: [BodyPartiallyStreamed] -> ShowS |
Constructors
ContentBuilder Builder | |
ContentFile FilePath | |
ContentStream StreamingBody | |
ContentResponse Response |
data ScottyResponse Source #
Instances
Default ScottyResponse Source # | |
Defined in Web.Scotty.Internal.Types Methods |
setContent :: Content -> ScottyResponse -> ScottyResponse Source #
setHeaderWith :: ([(HeaderName, ByteString)] -> [(HeaderName, ByteString)]) -> ScottyResponse -> ScottyResponse Source #
setStatus :: Status -> ScottyResponse -> ScottyResponse Source #
defaultScottyResponse :: ScottyResponse Source #
The default response has code 200 OK and empty body
Instances
MonadTransControl ActionT Source # | |
MonadTrans ActionT Source # | |
Defined in Web.Scotty.Internal.Types | |
MonadBaseControl b m => MonadBaseControl b (ActionT m) Source # | |
Defined in Web.Scotty.Internal.Types Associated Types type StM (ActionT m) a | |
MonadUnliftIO m => MonadError StatusError (ActionT m) Source # | Models the invariant that only |
Defined in Web.Scotty.Internal.Types Methods throwError :: StatusError -> ActionT m a catchError :: ActionT m a -> (StatusError -> ActionT m a) -> ActionT m a | |
Monad m => MonadReader ActionEnv (ActionT m) Source # | |
MonadBase b m => MonadBase b (ActionT m) Source # | |
Defined in Web.Scotty.Internal.Types | |
MonadIO m => MonadFail (ActionT m) Source # | Modeled after the behaviour in scotty < 0.20, |
Defined in Web.Scotty.Internal.Types | |
MonadIO m => MonadIO (ActionT m) Source # | |
Defined in Web.Scotty.Internal.Types | |
MonadUnliftIO m => Alternative (ActionT m) Source # |
|
Applicative m => Applicative (ActionT m) Source # | |
Functor m => Functor (ActionT m) Source # | |
Monad m => Monad (ActionT m) Source # | |
MonadUnliftIO m => MonadPlus (ActionT m) Source # | |
MonadCatch m => MonadCatch (ActionT m) Source # | |
Defined in Web.Scotty.Internal.Types | |
MonadThrow m => MonadThrow (ActionT m) Source # | |
Defined in Web.Scotty.Internal.Types | |
MonadUnliftIO m => MonadUnliftIO (ActionT m) Source # | |
Defined in Web.Scotty.Internal.Types Methods withRunInIO :: ((forall a. ActionT m a -> IO a) -> IO b) -> ActionT m b | |
(Monad m, Monoid a) => Monoid (ActionT m a) Source # | |
(Monad m, Semigroup a) => Semigroup (ActionT m a) Source # | |
type StT ActionT a Source # | |
Defined in Web.Scotty.Internal.Types | |
type StM (ActionT m) a Source # | |
Defined in Web.Scotty.Internal.Types |
tryAnyStatus :: MonadUnliftIO m => m a -> m Bool Source #
catches either ActionError (thrown by next
) or StatusError
(thrown if e.g. a query parameter is not found)
data RoutePattern Source #
Instances
IsString RoutePattern Source # | |
Defined in Web.Scotty.Internal.Types Methods fromString :: String -> RoutePattern |