Copyright | (C) 2021 2024 Bellroy Pty Ltd |
---|---|
License | BSD-3-Clause |
Maintainer | Bellroy Tech Team <haskell@bellroy.com> |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Lifts an Application
so that it can be run using
mRuntime
or
mRuntimeWithContext
. The glue code will look
something like this:
import AWS.Lambda.Runtime (mRuntime
) import Network.Wai (Application) import qualified Network.Wai.Handler.Hal as WaiHandler app :: Application app = undefined -- From Servant or wherever else main :: IO () main =mRuntime
$ WaiHandler.run
app
Synopsis
- run :: MonadIO m => Application -> ProxyRequest NoAuthorizer -> m ProxyResponse
- runWithOptions :: MonadIO m => Options -> Application -> ProxyRequest NoAuthorizer -> m ProxyResponse
- runWithContext :: MonadIO m => Options -> (Key LambdaContext -> Key (ProxyRequest NoAuthorizer) -> Application) -> LambdaContext -> ProxyRequest NoAuthorizer -> m ProxyResponse
- data Options = Options {
- vault :: Vault
- portNumber :: PortNumber
- binaryMediaTypes :: [MediaType]
- defaultOptions :: Options
- toWaiRequest :: Options -> ProxyRequest a -> IO Request
- fromWaiResponse :: Options -> Response -> IO ProxyResponse
Documentation
run :: MonadIO m => Application -> ProxyRequest NoAuthorizer -> m ProxyResponse Source #
Convert a WAI Application
into a function that can
be run by hal's mRuntime
. This is the simplest
form, and probably all that you'll need. See runWithContext
if
you have more complex needs.
:: MonadIO m | |
=> Options | Configuration options. |
-> Application | |
-> ProxyRequest NoAuthorizer | |
-> m ProxyResponse |
A variant of run
with configurable Options
. Useful if you
just want to override the binaryMediaTypes
setting but don't need
the rest of runWithContext'
s features.
Since: 0.4.0.0
:: MonadIO m | |
=> Options | Configuration options. |
-> (Key LambdaContext -> Key (ProxyRequest NoAuthorizer) -> Application) | We pass two
|
-> LambdaContext | |
-> ProxyRequest NoAuthorizer | We force |
-> m ProxyResponse |
Convert a WAI Application
into a function that can
be run by hal's mRuntimeWithContext
. This
function exposes all the configurable knobs.
Options that can be used to customize the behaviour of runWithContext
.
defaultOptions
provides sensible defaults.
Options | |
|
defaultOptions :: Options Source #
Default options for running Application
s on Lambda.
toWaiRequest :: Options -> ProxyRequest a -> IO Request Source #
Convert the request sent to a Lambda serving an API Gateway proxy integration into a WAI request.
Note: We aren't told the HTTP version the client is using, so we assume HTTP 1.1.
fromWaiResponse :: Options -> Response -> IO ProxyResponse Source #
Convert a WAI Response
into a hal
ProxyResponse
.