theam / aws-lambda-haskell-runtime

⚡Haskell runtime for AWS Lambda
https://theam.github.io/aws-lambda-haskell-runtime/
Other
269 stars 48 forks source link

Native support for API Gateway #62

Closed dnikolovv closed 4 years ago

dnikolovv commented 4 years ago

As exposing your Lambda through API Gateway is a very common approach, do you think it would make sense to add "native" support for it inside the runtime?

I'm thinking something like this:

generateLambdaDispatcher UseWithAPIGateway.

Passing UseWithAPIGateway will automatically adjust the plumbing underneath so it knows how to parse the incoming event and send back a well-formed response.

Then the handlers could look something like

-- This type will be provided by the runtime
data APIGatewayEvent e =
  APIGatewayEvent
    { resource :: String
    .....
    , body :: e }

handler :: APIGatewayEvent SomeValue -> Context -> IO (Either Error Response)
handler ...

I could submit a PR if you're interested.

NickSeagull commented 4 years ago

Hey, this is a great idea, a PR would be well appreciated. :)

dnikolovv commented 4 years ago

Closed by #63