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

fix(build): Server service uses generic body bound #306

Merged
merged 2 commits into from
Mar 28, 2020

Conversation

bnjjj
Copy link
Contributor

@bnjjj bnjjj commented Mar 28, 2020

Motivation

close #281

Solution

I choose to use BoxBodyas a generic body when the transport feature is disabled. Let me know if it's a good choice.

…hyperium#281

Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
@@ -49,7 +49,7 @@ pub fn generate<'a, T: Service<'a>>(service: &'a T, context: &T::Context) -> Tok
}
}

impl<T: #server_trait> Service<http::Request<HyperBody>> for #server_service<T> {
impl<T: #server_trait> Service<http::Request<RequestBody>> for #server_service<T> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So instead of making this accept a BoxBody we actually want to make this generic over it. So we can do something like:

impl<T, B> Service<http::Request<B>> for #server_service<T>
where
	T: #server_trait,
	B: HttpBody + Send + Sync + 'static,
	B::Error: Into<StdError> + Send + 'static,
{ ... }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated ! Thanks a lot for your help

…hyperium#281

Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you so much!

@LucioFranco LucioFranco changed the title fix(codegen): Generation of server code independent of tonic transport fix(build): Server service uses generic body bound Mar 28, 2020
@LucioFranco LucioFranco merged commit 5758b75 into hyperium:master Mar 28, 2020
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

Successfully merging this pull request may close these issues.

Generation of server code independent of tonic transport
2 participants