Skip to content

Commit

Permalink
feat(server): add to wrap generic accept steams
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Nov 15, 2017
1 parent a453ea1 commit e4864a2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ impl<B: AsRef<[u8]> + 'static> Http<B> {
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
Expand All @@ -221,11 +221,13 @@ impl<B: AsRef<[u8]> + 'static> Http<B> {
addr: listener.local_addr()?,
listener: listener,
};
Ok(self.serve(incoming, new_service))
Ok(self.serve_incoming(incoming, new_service))
}

//TODO: make public
fn serve<I, S, Bd>(&self, incoming: I, new_service: S) -> Serve<I, S>
/// 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<I, S, Bd>(&self, incoming: I, new_service: S) -> Serve<I, S>
where I: Stream<Error=::std::io::Error>,
I::Item: AsyncRead + AsyncWrite,
S: NewService<Request = Request, Response = Response<Bd>, Error = ::Error>,
Expand Down

0 comments on commit e4864a2

Please sign in to comment.