-
Notifications
You must be signed in to change notification settings - Fork 361
[RFC] Wrap interface for tower::Service<Request>
#404
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
Comments
I do find Proposition 2 more clean than prop 1, as an end user that is. |
What are the limitations of Prop 1 vs Prop 2? If the only difference is having |
Option 2 looks more clear to me. I link that I don't have to remember a different crate name to run the service, it's all in |
I agree that Prop 2 seems cleaner as well |
Looks like everyone's on agreement on this, and this will simplify the external interface quite a lot. 😄 Thanks, folks! |
I think prop 2 looks good. I would probably use cc @davidpdrsn may be interested |
I agree! This looks great 😃 |
+1 to seeing if we can use |
We'll be able to support For For |
Closing the ticket as this is now implemented in 84d41c9 |
Remark: This is a follow-up to #374 as I'm currently implementing it. See #401 for progress.
Background
Right now, the current implementation in
lambda_http::handler
takes a handler function that takes aRequest
and returns anIntoResponse
implementation. This allows to pass the wrapped handler function intolambda_runtime::run
directly. However, it has a few limitations.First,
Request
andIntoResponse
aren'tDeserialize
andSerialize
, butlambda_runtime::run
require those traits. It means we have to pass through an intermediateAdapter
to transform the requests and responses. This is currently handled bylambda_http::handler
. As a consequence, the current implementation doesn't allow taking alambda_runtime::Handler
implementation directly. It offers alambda_http::Handler
, which implements it.This causes some switching away from custom
Handler
traits towardstower::Service
. Ideally, we should allow users to providetower::Service<Request>
implementations, and handle the transformation under the hood on their behalf. However, due tolambda_runtime::run
's signature, we cannot do that as-is. We also cannot implementDeserialize
andSerialize
forRequest
andResponse
, as those are all foreign traits and types.Proposition 1: extension trait for
Service<Request>
Proposition 2: create a
lambda_http::run
wrapperProposition 3: your idea here
If you have an idea that gives a cleaner interface, let me know!
The text was updated successfully, but these errors were encountered: