diff --git a/examples/tls/src/main.rs b/examples/tls/src/main.rs index 2e0d55e3f..4ab0cbca2 100644 --- a/examples/tls/src/main.rs +++ b/examples/tls/src/main.rs @@ -42,7 +42,8 @@ fn main() { .header("LOCATION", "/index.html") .body(Body::Empty) }))) - .serve_ssl::<_, ()>("127.0.0.1:8443", &pkcs12).unwrap(); + .bind("127.0.0.1:8443").unwrap() + .start_ssl(&pkcs12).unwrap(); println!("Started http server: 127.0.0.1:8443"); let _ = sys.run(); diff --git a/examples/websocket-chat/src/main.rs b/examples/websocket-chat/src/main.rs index b553b5f24..1f168eb84 100644 --- a/examples/websocket-chat/src/main.rs +++ b/examples/websocket-chat/src/main.rs @@ -207,13 +207,14 @@ fn main() { .header("LOCATION", "/static/websocket.html") .body(Body::Empty) })) - // websocket + // websocket .resource("/ws/", |r| r.route().f(chat_route)) - // static resources + // static resources .resource("/static/{tail:.*}", |r| r.h(fs::StaticFiles::new("tail", "static/", true))) }) - .serve::<_, ()>("127.0.0.1:8080").unwrap(); + .bind("127.0.0.1:8080").unwrap() + .start().unwrap(); let _ = sys.run(); } diff --git a/guide/src/qs_3_5.md b/guide/src/qs_3_5.md index 36f843fb5..4afbff4fb 100644 --- a/guide/src/qs_3_5.md +++ b/guide/src/qs_3_5.md @@ -1,6 +1,7 @@ # Server + ## Multi-threading Http server automatically starts number of http workers, by default diff --git a/src/lib.rs b/src/lib.rs index 92ed2ea52..74b33f1e3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,7 +11,8 @@ //! HttpServer::new( //! || Application::new() //! .resource("/{name}", |r| r.f(index))) -//! .serve("127.0.0.1:8080"); +//! .bind("127.0.0.1:8080")? +//! .start() //! } //! ``` //! diff --git a/src/server.rs b/src/server.rs index f787621f5..5961a40a1 100644 --- a/src/server.rs +++ b/src/server.rs @@ -177,9 +177,8 @@ impl HttpServer /// Start listening for incomming connections from a stream. /// /// This method uses only one thread for handling incoming connections. - pub fn start_incoming(mut self, stream: S, secure: bool) -> io::Result - where Self: ActorAddress, - S: Stream + 'static + pub fn start_incoming(mut self, stream: S, secure: bool) -> io::Result> + where S: Stream + 'static { if !self.sockets.is_empty() { let addrs: Vec<(net::SocketAddr, Socket)> = self.sockets.drain().collect(); @@ -324,9 +323,7 @@ impl HttpServer, net::SocketAddr, H, V: IntoHttpHandler, { /// Start listening for incomming tls connections. - pub fn start_tls(mut self, pkcs12: ::Pkcs12) -> io::Result - where Self: ActorAddress, - { + pub fn start_tls(mut self, pkcs12: ::Pkcs12) -> io::Result> { if self.sockets.is_empty() { Err(io::Error::new(io::ErrorKind::Other, "No socket addresses are bound")) } else { @@ -363,9 +360,7 @@ impl HttpServer, net::SocketAddr, H, /// Start listening for incomming tls connections. /// /// This method sets alpn protocols to "h2" and "http/1.1" - pub fn start_ssl(mut self, identity: &ParsedPkcs12) -> io::Result - where Self: ActorAddress, - { + pub fn start_ssl(mut self, identity: &ParsedPkcs12) -> io::Result> { if self.sockets.is_empty() { Err(io::Error::new(io::ErrorKind::Other, "No socket addresses are bound")) } else {