Copyright | (C) 2021 Bellroy Pty Ltd |
---|---|
License | BSD-3-Clause |
Maintainer | Bellroy Tech Team <haskell@bellroy.com> |
Stability | experimental |
Safe Haskell | None |
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
- runWithContext :: MonadIO m => Vault -> PortNumber -> (Key LambdaContext -> Key (ProxyRequest NoAuthorizer) -> Application) -> LambdaContext -> ProxyRequest NoAuthorizer -> m ProxyResponse
- toWaiRequest :: Vault -> PortNumber -> ProxyRequest a -> IO Request
- fromWaiResponse :: 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 | |
=> Vault | Vault of values to share between the application and any
middleware. You can pass in |
-> PortNumber | API Gateway doesn't tell us the port it's listening on, so you have to tell it yourself. This is almost always going to be 443 (HTTPS). |
-> (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.
toWaiRequest :: Vault -> PortNumber -> 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 :: Response -> IO ProxyResponse Source #
Convert a WAI Response
into a hal
ProxyResponse
.