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

lambda_http::run forces the Tower service to implement FnMut... - so one cannot build a tower service nest #705

Closed
bassmanitram opened this issue Oct 13, 2023 · 4 comments

Comments

@bassmanitram
Copy link
Contributor

bassmanitram commented Oct 13, 2023

I'm attempting to build to build a tower service chain that calls the "real" HTTP handler after some library-implemented pre-handling logic. One of these is an attempt to use tower_http::AddExtensionLayer to add request-specific state object as an http::request::extension. This gives me this error:

222 |     lambda_http::run(service).await?;
    |     ^^^^^^^^^^^^^^^^ expected an `FnMut<(http::Request<Body>,)>` closure, found `THE TYPE OF THE STATE OBJECT`

So I have some unnatural gymnastics necessary now to make sure that the primary service nest is, indeed, FnMut<(http::Request,).

Any way this ease up this requirement?

@BMorinDrifter
Copy link
Contributor

Do you have a simple sample you can share?
Had to do a similar thing for my crate and found this problem a little easier to solve within the context of a single lambda function vs at the library scope.

@bassmanitram
Copy link
Contributor Author

OK, I'll attempt to do that

@bassmanitram
Copy link
Contributor Author

Well, it's one of those things that "went away" - it was likely to do with not having the correct combinations of Clone, Send and Sync (and maybe 'static) in the Service implementation I was trying.

@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

2 participants