aws-lambda-runtime-0: Haskell on AWS Lambda Runtime API

Safe HaskellNone
LanguageHaskell2010

AWS.Lambda.RuntimeAPI

Contents

Description

Based on the logic as implemented in https://github.com/awslabs/aws-lambda-cpp

Synopsis

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

data GenMock a Source #

How to mock the Request, what to do with the Response.

Constructors

Mock 

Fields

makeMockRequest Source #

Arguments

:: 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

data Response Source #

Constructors

SuccessResponse !MediaType !ByteString 
FailureResponse !Text !Text

error type, error message

Instances
Show Response Source # 
Instance details

Defined in AWS.Lambda.RuntimeAPI

NFData Response Source # 
Instance details

Defined in AWS.Lambda.RuntimeAPI

Methods

rnf :: Response -> () #

data GenRequest a Source #

Constructors

Request 

Fields

Instances
Functor GenRequest Source # 
Instance details

Defined in AWS.Lambda.RuntimeAPI

Methods

fmap :: (a -> b) -> GenRequest a -> GenRequest b #

(<$) :: a -> GenRequest b -> GenRequest a #

Foldable GenRequest Source # 
Instance details

Defined in AWS.Lambda.RuntimeAPI

Methods

fold :: Monoid m => GenRequest m -> m #

foldMap :: Monoid m => (a -> m) -> GenRequest a -> m #

foldr :: (a -> b -> b) -> b -> GenRequest a -> b #

foldr' :: (a -> b -> b) -> b -> GenRequest a -> b #

foldl :: (b -> a -> b) -> b -> GenRequest a -> b #

foldl' :: (b -> a -> b) -> b -> GenRequest a -> b #

foldr1 :: (a -> a -> a) -> GenRequest a -> a #

foldl1 :: (a -> a -> a) -> GenRequest a -> a #

toList :: GenRequest a -> [a] #

null :: GenRequest a -> Bool #

length :: GenRequest a -> Int #

elem :: Eq a => a -> GenRequest a -> Bool #

maximum :: Ord a => GenRequest a -> a #

minimum :: Ord a => GenRequest a -> a #

sum :: Num a => GenRequest a -> a #

product :: Num a => GenRequest a -> a #

Traversable GenRequest Source # 
Instance details

Defined in AWS.Lambda.RuntimeAPI

Methods

traverse :: Applicative f => (a -> f b) -> GenRequest a -> f (GenRequest b) #

sequenceA :: Applicative f => GenRequest (f a) -> f (GenRequest a) #

mapM :: Monad m => (a -> m b) -> GenRequest a -> m (GenRequest b) #

sequence :: Monad m => GenRequest (m a) -> m (GenRequest a) #

Show a => Show (GenRequest a) Source # 
Instance details

Defined in AWS.Lambda.RuntimeAPI

data RequestId Source #

Opaque request id

Instances
Show RequestId Source # 
Instance details

Defined in AWS.Lambda.RuntimeAPI

Time remaining

getTimeRemaining :: GenRequest a -> IO Int64 Source #

Get time remaining (milliseconds).

JSON responses

jsonResponse :: ToJSON a => a -> Response Source #

Create JSON response.