From e4864a2bea59b40fb07e6d18329f75817803a3f3 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Wed, 15 Nov 2017 13:39:24 -0800 Subject: [PATCH] feat(server): add to wrap generic accept steams --- src/server/mod.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 5b1e0834..4e2cd34e 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -204,10 +204,10 @@ impl + 'static> Http { self.bind(addr, self::compat_impl::new_service(new_service)) } - /// This method allows the ability to share a `Core` with multiple servers. - /// /// Bind the provided `addr` and return a server with a shared `Core`. /// + /// This method allows the ability to share a `Core` with multiple servers. + /// /// This is method will bind the `addr` provided with a new TCP listener ready /// to accept connections. Each connection will be processed with the /// `new_service` object provided as well, creating a new service per @@ -221,11 +221,13 @@ impl + 'static> Http { addr: listener.local_addr()?, listener: listener, }; - Ok(self.serve(incoming, new_service)) + Ok(self.serve_incoming(incoming, new_service)) } - //TODO: make public - fn serve(&self, incoming: I, new_service: S) -> Serve + /// Bind the provided stream of incoming IO objects with a `NewService`. + /// + /// This method allows the ability to share a `Core` with multiple servers. + pub fn serve_incoming(&self, incoming: I, new_service: S) -> Serve where I: Stream, I::Item: AsyncRead + AsyncWrite, S: NewService, Error = ::Error>,