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

feat(server): Remove into_service api #1996

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tonic/src/transport/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,7 @@ impl<L> Router<L> {
}

/// Create a tower service out of a router.
#[deprecated(since = "0.12.4", note = "compose the layers and the `Routes`")]
Copy link
Collaborator

Choose a reason for hiding this comment

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

So how would you spell this in 0.13?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What is the purpose? Should this api be kept in 0.13?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm asking what the replacement looks like, in order to better understand how much boilerplate this call is hiding.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see. In the case where this API is used, users can build Routes in advance, so they can set some layers to the Routes with some means, for example tower's ServiceBuilder.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand -- do you have a code snippet showing what that would look like?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The following is an example if using tower's ServiceBuilder:

let routes = Routes::new(service()).prepare();

let service = tower::ServiceBuilder::new()
    .layer(layer())
    .service(routes);

pub fn into_service<ResBody>(self) -> L::Service
where
L: Layer<Routes>,
Expand Down