Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Options = Options {}
- defaultOptions :: Options
- newtype RouteOptions = RouteOptions {}
- defaultRouteOptions :: RouteOptions
- type Kilobytes = Int
- type Middleware m = Application m -> Application m
- type Application m = Request -> m Response
- data BodyChunkBuffer = BodyChunkBuffer {}
- data BodyInfo = BodyInfo {}
- 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 :: 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 = 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 :: MonadUnliftIO m => InternalState -> ParseRequestBodyOptions -> ActionT m ([Param], [File FilePath])
- getResponse :: MonadIO m => ActionEnv -> m ScottyResponse
- getResponseAction :: MonadIO m => ActionT m ScottyResponse
- modifyResponse :: MonadIO m => (ScottyResponse -> ScottyResponse) -> ActionT m ()
- data BodyPartiallyStreamed = BodyPartiallyStreamed
- data Content
- 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 {}
- withActionEnv :: Monad m => (ActionEnv -> ActionEnv) -> ActionT m a -> ActionT m a
- tryAnyStatus :: MonadUnliftIO m => m a -> m Bool
- data RoutePattern
Documentation
Options | |
|
newtype RouteOptions Source #
Instances
Default RouteOptions Source # | |
Defined in Web.Scotty.Internal.Types def :: RouteOptions # |
type Middleware m = Application m -> Application m Source #
type Application m = Request -> m Response Source #
data BodyChunkBuffer Source #
BodyChunkBuffer | |
|
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)
BodyInfo | |
|
data ScottyState m Source #
ScottyState | |
|
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 #
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.
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 | |
Show ActionError Source # | |
Defined in Web.Scotty.Internal.Types showsPrec :: Int -> ActionError -> ShowS # show :: ActionError -> String # showList :: [ActionError] -> ShowS # |
tryNext :: MonadUnliftIO m => m a -> m Bool Source #
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)
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 | |
Show StatusError Source # | |
Defined in Web.Scotty.Internal.Types 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 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
Instances
Exception ScottyException Source # | |
Defined in Web.Scotty.Internal.Types | |
Show ScottyException Source # | |
Defined in Web.Scotty.Internal.Types 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.
Env | |
|
formParamsAndFilesWith :: MonadUnliftIO m => InternalState -> ParseRequestBodyOptions -> ActionT m ([Param], [File FilePath]) Source #
getResponse :: MonadIO m => ActionEnv -> m ScottyResponse Source #
getResponseAction :: MonadIO m => ActionT m ScottyResponse Source #
modifyResponse :: MonadIO m => (ScottyResponse -> ScottyResponse) -> ActionT m () Source #
data BodyPartiallyStreamed Source #
Instances
Exception BodyPartiallyStreamed Source # | |
Show BodyPartiallyStreamed Source # | |
Defined in Web.Scotty.Internal.Types showsPrec :: Int -> BodyPartiallyStreamed -> ShowS # show :: BodyPartiallyStreamed -> String # showList :: [BodyPartiallyStreamed] -> ShowS # |
data ScottyResponse Source #
Instances
Default ScottyResponse Source # | |
Defined in Web.Scotty.Internal.Types def :: ScottyResponse # |
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
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 fromString :: String -> RoutePattern # |