Skip to content

How to wrap a Handler into another one #373

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

Closed
nmoutschen opened this issue Nov 23, 2021 · 2 comments
Closed

How to wrap a Handler into another one #373

nmoutschen opened this issue Nov 23, 2021 · 2 comments

Comments

@nmoutschen
Copy link
Contributor

Hey folks!

I'm doing a proof-of-concept of wrapping a lambda_runtime::Handler into another one. The idea is that I could then add and chain capabilities with a nice interface.

However, I'm facing an issue in how I call the actual function, since the Handler trait has a synchronous function call() that returns a Future. That means that I cannot await the function's call and then do something with the result. How could I handle that?

Here's the POC I currently have, with the problem highlighted: https://gist.github.com/nmoutschen/5a264d1d2d246d265517962ff91cba8c#file-wrap_handler-rs-L33

If I wrap the call into an async {} block, I then get the following error:

mismatched types
expected type parameter `Fut`
      found opaque type `impl Future`
@Mdrbhatti
Copy link
Contributor

@nmoutschen you might find the following example helpful.
https://github.com/Mdrbhatti/warp_lambda/blob/main/src/lib.rs#L121

@nmoutschen
Copy link
Contributor Author

Thanks a lot @Mdrbhatti ! It's working now! 😄

If anyone is interested, here's the code for reference: https://gist.github.com/nmoutschen/5a264d1d2d246d265517962ff91cba8c

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

No branches or pull requests

2 participants