Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for async/await in handler #52

Closed
lmammino opened this issue Nov 19, 2017 · 0 comments
Closed

Support for async/await in handler #52

lmammino opened this issue Nov 19, 2017 · 0 comments

Comments

@lmammino
Copy link
Member

lmammino commented Nov 19, 2017

Since version 0.3.0 we have support for async/await in middlewares.

We could potentially apply the same approach to the handler. Since the handler is invoked and managed by the middy wrapper, we could support different syntaxes including handlers returning promises and consequently async/await handlers.

These are the two syntaxes I envision might be cool to support:

const handler = middy((event, context) => {
  return Promise.resolve({
    statusCode: 200,
    body: 'hello'
  })
})

and, with async/await:

const handler = middy(async (event, context) => {
  return {
    statusCode: 200,
    body: 'hello'
  }
})

Any thoughts?

I think this is feasible by addressing the handler runtime logic here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant