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 :: 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
- 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
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 | |
|
Instances
Default (ScottyState m) Source # | |
Defined in Web.Scotty.Internal.Types 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 #
ScottyT | |
|
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 #
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)
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 # |
Env | |
|
getResponse :: MonadIO m => ActionEnv -> 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
) 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 fromString :: String -> RoutePattern # |