feat(server): add to wrap generic accept steams
This commit is contained in:
@@ -204,10 +204,10 @@ impl<B: AsRef<[u8]> + 'static> Http<B> {
|
|||||||
self.bind(addr, self::compat_impl::new_service(new_service))
|
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`.
|
/// 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
|
/// This is method will bind the `addr` provided with a new TCP listener ready
|
||||||
/// to accept connections. Each connection will be processed with the
|
/// to accept connections. Each connection will be processed with the
|
||||||
/// `new_service` object provided as well, creating a new service per
|
/// `new_service` object provided as well, creating a new service per
|
||||||
@@ -221,11 +221,13 @@ impl<B: AsRef<[u8]> + 'static> Http<B> {
|
|||||||
addr: listener.local_addr()?,
|
addr: listener.local_addr()?,
|
||||||
listener: listener,
|
listener: listener,
|
||||||
};
|
};
|
||||||
Ok(self.serve(incoming, new_service))
|
Ok(self.serve_incoming(incoming, new_service))
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: make public
|
/// Bind the provided stream of incoming IO objects with a `NewService`.
|
||||||
fn serve<I, S, Bd>(&self, incoming: I, new_service: S) -> Serve<I, S>
|
///
|
||||||
|
/// 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>,
|
where I: Stream<Error=::std::io::Error>,
|
||||||
I::Item: AsyncRead + AsyncWrite,
|
I::Item: AsyncRead + AsyncWrite,
|
||||||
S: NewService<Request = Request, Response = Response<Bd>, Error = ::Error>,
|
S: NewService<Request = Request, Response = Response<Bd>, Error = ::Error>,
|
||||||
|
|||||||
Reference in New Issue
Block a user