1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-24 07:53:00 +01:00

update examples

This commit is contained in:
Nikolay Kim 2017-12-18 13:06:41 -08:00
parent 27d92f3a23
commit 9ed4159c0c
5 changed files with 13 additions and 14 deletions

View File

@ -42,7 +42,8 @@ fn main() {
.header("LOCATION", "/index.html") .header("LOCATION", "/index.html")
.body(Body::Empty) .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"); println!("Started http server: 127.0.0.1:8443");
let _ = sys.run(); let _ = sys.run();

View File

@ -213,7 +213,8 @@ fn main() {
.resource("/static/{tail:.*}", .resource("/static/{tail:.*}",
|r| r.h(fs::StaticFiles::new("tail", "static/", true))) |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(); let _ = sys.run();
} }

View File

@ -1,6 +1,7 @@
# Server # Server
## Multi-threading ## Multi-threading
Http server automatically starts number of http workers, by default Http server automatically starts number of http workers, by default

View File

@ -11,7 +11,8 @@
//! HttpServer::new( //! HttpServer::new(
//! || Application::new() //! || Application::new()
//! .resource("/{name}", |r| r.f(index))) //! .resource("/{name}", |r| r.f(index)))
//! .serve("127.0.0.1:8080"); //! .bind("127.0.0.1:8080")?
//! .start()
//! } //! }
//! ``` //! ```
//! //!

View File

@ -177,9 +177,8 @@ impl<T, A, H, U, V> HttpServer<T, A, H, U>
/// Start listening for incomming connections from a stream. /// Start listening for incomming connections from a stream.
/// ///
/// This method uses only one thread for handling incoming connections. /// This method uses only one thread for handling incoming connections.
pub fn start_incoming<S, Addr>(mut self, stream: S, secure: bool) -> io::Result<Addr> pub fn start_incoming<S>(mut self, stream: S, secure: bool) -> io::Result<SyncAddress<Self>>
where Self: ActorAddress<Self, Addr>, where S: Stream<Item=(T, A), Error=io::Error> + 'static
S: Stream<Item=(T, A), Error=io::Error> + 'static
{ {
if !self.sockets.is_empty() { if !self.sockets.is_empty() {
let addrs: Vec<(net::SocketAddr, Socket)> = self.sockets.drain().collect(); let addrs: Vec<(net::SocketAddr, Socket)> = self.sockets.drain().collect();
@ -324,9 +323,7 @@ impl<H: HttpHandler, U, V> HttpServer<TlsStream<TcpStream>, net::SocketAddr, H,
V: IntoHttpHandler<Handler=H>, V: IntoHttpHandler<Handler=H>,
{ {
/// Start listening for incomming tls connections. /// Start listening for incomming tls connections.
pub fn start_tls<Addr>(mut self, pkcs12: ::Pkcs12) -> io::Result<Addr> pub fn start_tls(mut self, pkcs12: ::Pkcs12) -> io::Result<SyncAddress<Self>> {
where Self: ActorAddress<Self, Addr>,
{
if self.sockets.is_empty() { if self.sockets.is_empty() {
Err(io::Error::new(io::ErrorKind::Other, "No socket addresses are bound")) Err(io::Error::new(io::ErrorKind::Other, "No socket addresses are bound"))
} else { } else {
@ -363,9 +360,7 @@ impl<H: HttpHandler, U, V> HttpServer<SslStream<TcpStream>, net::SocketAddr, H,
/// Start listening for incomming tls connections. /// Start listening for incomming tls connections.
/// ///
/// This method sets alpn protocols to "h2" and "http/1.1" /// This method sets alpn protocols to "h2" and "http/1.1"
pub fn start_ssl<Addr>(mut self, identity: &ParsedPkcs12) -> io::Result<Addr> pub fn start_ssl(mut self, identity: &ParsedPkcs12) -> io::Result<SyncAddress<Self>> {
where Self: ActorAddress<Self, Addr>,
{
if self.sockets.is_empty() { if self.sockets.is_empty() {
Err(io::Error::new(io::ErrorKind::Other, "No socket addresses are bound")) Err(io::Error::new(io::ErrorKind::Other, "No socket addresses are bound"))
} else { } else {