| Safe Haskell | None |
|---|---|
| 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 :: Type -> Type) = Application m -> Application m
- type Application (m :: Type -> Type) = 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 :: Type -> Type) = ScottyState {
- middlewares :: [Middleware]
- routes :: [BodyInfo -> Middleware m]
- handler :: Maybe (ErrorHandler m)
- routeOptions :: RouteOptions
- defaultScottyState :: forall (m :: Type -> Type). ScottyState m
- addMiddleware :: forall (m :: Type -> Type). Middleware -> ScottyState m -> ScottyState m
- addRoute :: (BodyInfo -> Middleware m) -> ScottyState m -> ScottyState m
- setHandler :: forall (m :: Type -> Type). Maybe (ErrorHandler m) -> ScottyState m -> ScottyState m
- updateMaxRequestBodySize :: forall (m :: Type -> Type). RouteOptions -> ScottyState m -> ScottyState m
- newtype ScottyT (m :: Type -> Type) a = ScottyT {
- runS :: ReaderT Options (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 :: Type -> Type) = Handler (ActionT m) ()
- data ScottyException
- = RequestTooLarge
- | MalformedJSON ByteString Text
- | FailedToParseJSON ByteString Text
- | PathParameterNotFound Text
- | QueryParameterNotFound Text
- | FormFieldNotFound Text
- | FailedToParseParameter Text Text Text
- | WarpRequestException InvalidRequest
- | WaiRequestParseException RequestParseException
- | ResourceTException InvalidAccess
- type Param = (Text, Text)
- type File t = (Text, FileInfo t)
- data ActionEnv = Env {
- envReq :: Request
- envPathParams :: [Param]
- envQueryParams :: [Param]
- envFormDataAction :: InternalState -> ParseRequestBodyOptions -> IO ([Param], [File FilePath])
- envBody :: IO ByteString
- envBodyChunk :: IO ByteString
- envResponse :: TVar ScottyResponse
- formParamsAndFilesWith :: forall (m :: Type -> Type). MonadUnliftIO m => InternalState -> ParseRequestBodyOptions -> ActionT m ([Param], [File FilePath])
- getResponse :: MonadIO m => ActionEnv -> m ScottyResponse
- getResponseAction :: forall (m :: Type -> Type). MonadIO m => ActionT m ScottyResponse
- modifyResponse :: forall (m :: Type -> Type). 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 :: Type -> Type) a = ActionT {}
- withActionEnv :: forall (m :: Type -> Type) a. Monad m => (ActionEnv -> ActionEnv) -> ActionT m a -> ActionT m a
- 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 :: Type -> Type) = Application m -> Application m Source #
type Application (m :: Type -> Type) = 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 :: Type -> Type) Source #
Constructors
| ScottyState | |
Fields
| |
defaultScottyState :: forall (m :: Type -> Type). ScottyState m Source #
addMiddleware :: forall (m :: Type -> Type). Middleware -> ScottyState m -> ScottyState m Source #
addRoute :: (BodyInfo -> Middleware m) -> ScottyState m -> ScottyState m Source #
setHandler :: forall (m :: Type -> Type). Maybe (ErrorHandler m) -> ScottyState m -> ScottyState m Source #
updateMaxRequestBodySize :: forall (m :: Type -> Type). RouteOptions -> ScottyState m -> ScottyState m Source #
newtype ScottyT (m :: Type -> Type) a 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 backtraceDesired :: ActionError -> Bool | |
| Show ActionError Source # | |
Defined in Web.Scotty.Internal.Types Methods showsPrec :: Int -> ActionError -> ShowS show :: ActionError -> String showList :: [ActionError] -> ShowS | |
data StatusError Source #
Deprecated: If it is supposed to be caught, a proper exception type should be defined
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 | Deprecated: If it is supposed to be caught, a proper exception type should be defined |
Instances
| Exception StatusError Source # | |
Defined in Web.Scotty.Internal.Types Methods toException :: StatusError -> SomeException fromException :: SomeException -> Maybe StatusError displayException :: StatusError -> String backtraceDesired :: StatusError -> Bool | |
| 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 | |
type ErrorHandler (m :: Type -> Type) = Handler (ActionT m) () Source #
data ScottyException Source #
Thrown e.g. when a request is too large
Constructors
| RequestTooLarge | |
| MalformedJSON ByteString Text | |
| FailedToParseJSON ByteString Text | |
| PathParameterNotFound Text | |
| QueryParameterNotFound Text | |
| FormFieldNotFound Text | |
| FailedToParseParameter Text Text Text | |
| WarpRequestException InvalidRequest | |
| WaiRequestParseException RequestParseException | |
| ResourceTException InvalidAccess |
Instances
| Exception ScottyException Source # | |
Defined in Web.Scotty.Internal.Types Methods toException :: ScottyException -> SomeException fromException :: SomeException -> Maybe ScottyException displayException :: ScottyException -> String backtraceDesired :: ScottyException -> Bool | |
| Show ScottyException Source # | |
Defined in Web.Scotty.Internal.Types Methods showsPrec :: Int -> ScottyException -> ShowS show :: ScottyException -> String showList :: [ScottyException] -> ShowS | |
type File t = (Text, FileInfo t) Source #
Type parameter t is the file content. Could be () when not needed or a FilePath for temp files instead.
Constructors
| Env | |
Fields
| |
formParamsAndFilesWith :: forall (m :: Type -> Type). MonadUnliftIO m => InternalState -> ParseRequestBodyOptions -> ActionT m ([Param], [File FilePath]) Source #
getResponse :: MonadIO m => ActionEnv -> m ScottyResponse Source #
getResponseAction :: forall (m :: Type -> Type). MonadIO m => ActionT m ScottyResponse Source #
modifyResponse :: forall (m :: Type -> Type). 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 backtraceDesired :: BodyPartiallyStreamed -> Bool | |
| 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
newtype ActionT (m :: Type -> Type) a Source #
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 | |
| 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 | |
| MonadReader r m => MonadReader r (ActionT m) Source # | |
| MonadBase b m => MonadBase b (ActionT m) Source # | |
Defined in Web.Scotty.Internal.Types | |
| MonadIO m => MonadIO (ActionT m) Source # | |
Defined in Web.Scotty.Internal.Types | |
| 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 => 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 # | |
| MonadIO m => MonadFail (ActionT m) Source # | Modeled after the behaviour in scotty < 0.20, |
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 | |
withActionEnv :: forall (m :: Type -> Type) a. Monad m => (ActionEnv -> ActionEnv) -> ActionT m a -> ActionT m a Source #
tryAnyStatus :: MonadUnliftIO m => m a -> m Bool Source #
catches either ActionError (thrown by next),
ScottyException (thrown if e.g. a query parameter is not found)
or StatusError (via raiseStatus)
data RoutePattern Source #
Instances
| IsString RoutePattern Source # | |
Defined in Web.Scotty.Internal.Types Methods fromString :: String -> RoutePattern | |