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

Expose Router::into_service #269

Closed
LucioFranco opened this issue Feb 16, 2020 · 5 comments
Closed

Expose Router::into_service #269

LucioFranco opened this issue Feb 16, 2020 · 5 comments
Labels
A-tonic E-easy Call for participation: Experience needed to fix: Easy / not much E-help-wanted Call for participation: Help is requested to fix this issue.

Comments

@LucioFranco
Copy link
Member

We should expose something akin to warp::service that allows the Router type to turn into a Service implementation so that it can be combined with more custom implementations.

@LucioFranco LucioFranco added E-help-wanted Call for participation: Help is requested to fix this issue. E-easy Call for participation: Experience needed to fix: Easy / not much A-tonic labels Feb 16, 2020
@cthulhua
Copy link
Contributor

Took a look at this; do we kind of want the opposite tack here of tonic::transport::Server? ie rather than a 'batteries included' approach, literally just turn a Router into a Service and let users compose that service however they want?

@LucioFranco
Copy link
Member Author

@cthulhua well I think one goal of the transport was to remove the need to worry about services unless you really need to. So I think providing this into_service would allow users that want to do more advanced things with tower use the router infrastructure.

@cthulhua
Copy link
Contributor

Ok; I took a crack at this...literally just a RouterService with

    #[inline]
    fn call(&mut self, req: Request<Body>) -> Self::Future {
        self.router.routes.call(req)
    }

I'll add some tests and open a PR; is there anything more we want here?

@cthulhua
Copy link
Contributor

started draft pr:
#272

@alce
Copy link
Collaborator

alce commented Sep 20, 2020

Resolved via #419

@alce alce closed this as completed Sep 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tonic E-easy Call for participation: Experience needed to fix: Easy / not much E-help-wanted Call for participation: Help is requested to fix this issue.
Projects
None yet
Development

No branches or pull requests

3 participants