Function from_tcp
Source pub fn from_tcp(listener: TcpListener) -> Server
Expand description
Create a Server
from existing std::net::TcpListener
.
examples/from_std_listener.rs (
line 15)
9async fn main() {
10 let app = Router::new().route("/", get(|| async { "Hello, world!" }));
11
12 let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
13 let listener = TcpListener::bind(addr).unwrap();
14 println!("listening on {}", addr);
15 hyper_serve::from_tcp(listener)
16 .serve(app.into_make_service())
17 .await
18 .unwrap();
19}