Safe Haskell | None |
---|---|
Language | Haskell2010 |
Based on the logic as implemented in https://github.com/awslabs/aws-lambda-cpp
Synopsis
- defaultMain :: (Request -> IO Response) -> IO ()
- jsonMain :: (FromJSON a, ToJSON b) => (GenRequest a -> IO b) -> IO ()
- autoMockMain :: Mock -> (Request -> IO Response) -> IO ()
- autoMockJsonMain :: (FromJSON a, ToJSON b) => GenMock a -> (GenRequest a -> IO b) -> IO ()
- type Mock = GenMock ByteString
- data GenMock a = Mock {
- mockRequest :: IO (GenRequest a)
- mockResponse :: Response -> IO ()
- makeMockRequest :: a -> Int64 -> IO (GenRequest a)
- type Request = GenRequest ByteString
- data Response
- data GenRequest a = Request {
- requestPayload :: !a
- requestId :: !RequestId
- requestXRayTraceId :: !ByteString
- requestClientContext :: !ByteString
- requestCognitoIdentity :: !ByteString
- requestARN :: !ByteString
- requestDeadline :: !Deadline
- data RequestId
- getTimeRemaining :: GenRequest a -> IO Int64
- jsonResponse :: ToJSON a => a -> Response
- jsonMediaType :: MediaType
Entry points
defaultMain :: (Request -> IO Response) -> IO () Source #
Default main to implement AWS Lambda using Runtime API
jsonMain :: (FromJSON a, ToJSON b) => (GenRequest a -> IO b) -> IO () Source #
Like defaultMain
but work with JSON
Mocks
autoMockMain :: Mock -> (Request -> IO Response) -> IO () Source #
Check the existence of AWS_LAMBDA_RUNTIME_API
environment variable.
If it exists, assume we are running in AWS Lambda environment, i.e. run normally.
Otherwise use supplied MockOptions
autoMockJsonMain :: (FromJSON a, ToJSON b) => GenMock a -> (GenRequest a -> IO b) -> IO () Source #
Like autoMockMain
but works with JSON
type Mock = GenMock ByteString Source #
Mock | |
|
:: a | payload value |
-> Int64 | request duration (in milliseconds) |
-> IO (GenRequest a) |
Create Mock
request
Requests and response
type Request = GenRequest ByteString Source #
Request with ByteString
payload
SuccessResponse !MediaType !ByteString | |
FailureResponse !Text !Text | error type, error message |
data GenRequest a Source #
Request | |
|
Instances
Opaque request id
Time remaining
getTimeRemaining :: GenRequest a -> IO Int64 Source #
Get time remaining (milliseconds).
JSON responses
jsonResponse :: ToJSON a => a -> Response Source #
Create JSON response.