From 0bf29a522b89d73b7ef8d17282ef0d011e6c5940 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 7 Mar 2018 11:28:44 -0800 Subject: [PATCH] Allow to use std::net::TcpListener for HttpServer --- CHANGES.md | 2 ++ src/server/srv.rs | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index fe8cdc506..4ab0c5239 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -17,6 +17,8 @@ * Allow client connection timeout to be set #108 +* Allow to use std::net::TcpListener for HttpServer + ## 0.4.4 (2018-03-04) diff --git a/src/server/srv.rs b/src/server/srv.rs index 33a7e432a..627f7a32f 100644 --- a/src/server/srv.rs +++ b/src/server/srv.rs @@ -173,6 +173,14 @@ impl HttpServer where H: IntoHttpHandler + 'static self.sockets.keys().cloned().collect() } + /// Use listener for accepting incoming connection requests + /// + /// HttpServer does not change any configuration for TcpListener, + /// it needs to be configured before passing it to listen() method. + pub fn listen(mut self, lst: net::TcpListener) { + self.sockets.insert(lst.local_addr().unwrap(), lst); + } + /// The socket address to bind /// /// To mind multiple addresses this method can be call multiple times.