wai-lambda-0.1.1.0: Haskell Webapps on AWS Lambda
Safe HaskellSafe-Inferred
LanguageHaskell2010

Network.Wai.Handler.Lambda

Synopsis

Documentation

type RawResponse = (Status, ResponseHeaders, ByteString) Source #

The representation of the response sent back to API Gateway.

data Settings Source #

The settings for running an Application.

See also: * runSettings

For simplicity use the following setters with defaultSettings: * setTimeoutSeconds * setHandleTimeout * setHandleException

Constructors

Settings 

Fields

run :: Application -> IO () Source #

Run an Application.

Continuously reads requests from stdin. Each line should be a a JSON document as described in decodeInput.

All requests will be timed out after 2 seconds. If any exception is thrown while processing the request this will return an HTTP 500 Internal Server Error.

If you need more control use handleRequest directly.

defaultTimeoutValue :: Int Source #

Default request timeout. 2 seconds.

handleRequest Source #

Arguments

:: Settings 
-> Application 
-> ByteString

The request (see decodeInput)

-> IO () 

Parse and handle the request.

  • Returns 504 if no response is available after the specified timeout.
  • Returns 500 if an exception occurs while processing the request.
  • Throws an exception if the input cannot be parsed.

processRequest :: Application -> Request -> IO Response Source #

Run the Request through the Application.

This function is completely dependent on the 'Application. Any exception thrown by the Application will be rethrown here. No timeout is implemented: if the Application never provides a Response then processRequest won't return.

decodeInput :: ByteString -> Either (JSONPath, String) (FilePath, IO Request) Source #

Decode a ByteString into (1) a Wai Request and (2) a filepath where the response should be written. The argument is JSON document with two fields: * request: the API Gateway request (see parseRequest) * reqsponseFile: Where to write the API Gateway response (see toJSONResponse)

data ApiGatewayRequestV2 Source #

Instances

Instances details
FromJSON ApiGatewayRequestV2 Source # 
Instance details

Defined in Network.Wai.Handler.Lambda

ToJSON ApiGatewayRequestV2 Source # 
Instance details

Defined in Network.Wai.Handler.Lambda

Generic ApiGatewayRequestV2 Source # 
Instance details

Defined in Network.Wai.Handler.Lambda

Associated Types

type Rep ApiGatewayRequestV2 :: Type -> Type #

Show ApiGatewayRequestV2 Source # 
Instance details

Defined in Network.Wai.Handler.Lambda

NFData ApiGatewayRequestV2 Source # 
Instance details

Defined in Network.Wai.Handler.Lambda

Methods

rnf :: ApiGatewayRequestV2 -> () #

type Rep ApiGatewayRequestV2 Source # 
Instance details

Defined in Network.Wai.Handler.Lambda

type Rep ApiGatewayRequestV2 = D1 ('MetaData "ApiGatewayRequestV2" "Network.Wai.Handler.Lambda" "wai-lambda-0.1.1.0-4kQWDCgzrvk3aqacUHRdqT" 'False) (C1 ('MetaCons "ApiGatewayRequestV2" 'PrefixI 'True) ((S1 ('MetaSel ('Just "body") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Text)) :*: (S1 ('MetaSel ('Just "headers") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (HashMap Text Text)) :*: S1 ('MetaSel ('Just "rawQueryString") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Text)))) :*: (S1 ('MetaSel ('Just "requestContext") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RequestContext) :*: (S1 ('MetaSel ('Just "cookies") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe [Text])) :*: S1 ('MetaSel ('Just "isBase64Encoded") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)))))

data RequestContext Source #

Constructors

RequestContext 

Fields

Instances

Instances details
FromJSON RequestContext Source # 
Instance details

Defined in Network.Wai.Handler.Lambda

ToJSON RequestContext Source # 
Instance details

Defined in Network.Wai.Handler.Lambda

Generic RequestContext Source # 
Instance details

Defined in Network.Wai.Handler.Lambda

Associated Types

type Rep RequestContext :: Type -> Type #

Show RequestContext Source # 
Instance details

Defined in Network.Wai.Handler.Lambda

NFData RequestContext Source # 
Instance details

Defined in Network.Wai.Handler.Lambda

Methods

rnf :: RequestContext -> () #

type Rep RequestContext Source # 
Instance details

Defined in Network.Wai.Handler.Lambda

type Rep RequestContext = D1 ('MetaData "RequestContext" "Network.Wai.Handler.Lambda" "wai-lambda-0.1.1.0-4kQWDCgzrvk3aqacUHRdqT" 'False) (C1 ('MetaCons "RequestContext" 'PrefixI 'True) ((S1 ('MetaSel ('Just "accountId") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Just "apiId") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text)) :*: (S1 ('MetaSel ('Just "domainName") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: (S1 ('MetaSel ('Just "http") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Http) :*: S1 ('MetaSel ('Just "requestId") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text)))))

data Http Source #

Constructors

Http 

Fields

Instances

Instances details
FromJSON Http Source # 
Instance details

Defined in Network.Wai.Handler.Lambda

ToJSON Http Source # 
Instance details

Defined in Network.Wai.Handler.Lambda

Generic Http Source # 
Instance details

Defined in Network.Wai.Handler.Lambda

Associated Types

type Rep Http :: Type -> Type #

Methods

from :: Http -> Rep Http x #

to :: Rep Http x -> Http #

Show Http Source # 
Instance details

Defined in Network.Wai.Handler.Lambda

Methods

showsPrec :: Int -> Http -> ShowS #

show :: Http -> String #

showList :: [Http] -> ShowS #

NFData Http Source # 
Instance details

Defined in Network.Wai.Handler.Lambda

Methods

rnf :: Http -> () #

type Rep Http Source # 
Instance details

Defined in Network.Wai.Handler.Lambda

type Rep Http = D1 ('MetaData "Http" "Network.Wai.Handler.Lambda" "wai-lambda-0.1.1.0-4kQWDCgzrvk3aqacUHRdqT" 'False) (C1 ('MetaCons "Http" 'PrefixI 'True) ((S1 ('MetaSel ('Just "method") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Just "path") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text)) :*: (S1 ('MetaSel ('Just "protocol") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text) :*: S1 ('MetaSel ('Just "sourceIp") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text))))

readResponse :: Response -> IO RawResponse Source #

Read the status, headers and body of a Response.

writeFileAtomic :: FilePath -> ByteString -> IO () Source #

Atomically write the ByteString to the file.

Uses rename(2).

xif :: b -> ((b -> c) -> b -> c) -> c Source #

flip fix

uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d Source #