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

Is it possible to use with non-TCP connections? (e.g. UDS) #92

Open
kornelski opened this issue Jul 10, 2021 · 4 comments
Open

Is it possible to use with non-TCP connections? (e.g. UDS) #92

kornelski opened this issue Jul 10, 2021 · 4 comments

Comments

@kornelski
Copy link

It looks like the RouterService hardcodes use of TCP-specific AddrStream:

fn call(&mut self, conn: &AddrStream) -> Self::Future {

I'm trying to accept HTTP requests over a Unix Domain Socket, which is incompatible with AddrStream.

Could you make this arg generic?

Second problem is that the service can't be cloned, so I can't do:

    hyper_builder.serve(make_service_fn(move |_| {
                            let s = router.clone();
                            async move { Ok(s) }
                        })).boxed()

I have to use Service trait and make_service_fn, because actual trait used serve is private. Unfortunately, the make_service_fn requires creating a new object each time.

@seanpianka
Copy link
Member

I added something similar to #93 in #75, perhaps you can build a new router with a shared reference to the builder, rather than cloning the router explicitly? I can provide a MCVE if needed.

@kornelski
Copy link
Author

Unfortunately .build() is router-specific, and I'm trying to use the router in a generic server context that takes Service<Request<Body>> + Clone.

@seanpianka
Copy link
Member

Have you tried using the RequestService instead of the RouterService? It strictly handles processing of the hyper::Request instance, rather than involving Routerify in the serving of the UDS or TCP-specific type.

There is examples/aws_lambda.rs that illustrates the approach. It would involve some marshaling of the request and response (shown earlier in that same example).

Let me know if you've already figured this out, so we can close the issue. Thanks!

@kornelski
Copy link
Author

I haven't figured it out, and switched from Routerify to my own router implementation.

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