Skip to content

lambda_http: Use http_body::Body for responses #409

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 Jan 27, 2022 · 5 comments
Closed

lambda_http: Use http_body::Body for responses #409

nmoutschen opened this issue Jan 27, 2022 · 5 comments

Comments

@nmoutschen
Copy link
Contributor

Since #406, lambda_http::Body implements http_body::Body. However, lambda_http::LambdaResponse only accepts lambda_http::Body as response body.

With this proposal, we could create a LambdaResponse from any Request<http_body::Body>, which means Lambda functions could return anything that implements this trait.

Drawbacks

Right now, we support receiving a serde_json::Value or other values that implement Into<Body> because we use a custom type.

I think this would no longer be possible if we accept a foreign trait, or would involve a bit more complexities on the implementation side.

@bnusunny
Copy link
Contributor

bnusunny commented Feb 4, 2022

This will be very useful. For example, in AWS Lambda Adapter, I have to convert from reqwest::Response to lambda_http::LambdaResponse. If this conversion is handled by lambda-http, it will help to remove big chunck of code from Lambda Adapter.

@calavera
Copy link
Contributor

calavera commented Feb 9, 2022

I think this would no longer be possible if we accept a foreign trait, or would involve a bit more complexities on the implementation side.

I think we need to see before/after examples of how this would work.

@calavera
Copy link
Contributor

this can be closed as fixed now, can't it?

@bnusunny
Copy link
Contributor

Yes, this was done in #491.

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for the maintainers of this repository to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

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

3 participants