mirror of
https://github.com/actix/actix-web.git
synced 2024-12-16 21:26:34 +00:00
update examples
This commit is contained in:
parent
27d92f3a23
commit
9ed4159c0c
5 changed files with 13 additions and 14 deletions
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# Server
|
||||
|
||||
|
||||
|
||||
## Multi-threading
|
||||
|
||||
Http server automatically starts number of http workers, by default
|
||||
|
|
|
@ -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()
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
|
|
|
@ -177,9 +177,8 @@ impl<T, A, H, U, V> HttpServer<T, A, H, U>
|
|||
/// Start listening for incomming connections from a stream.
|
||||
///
|
||||
/// 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>
|
||||
where Self: ActorAddress<Self, Addr>,
|
||||
S: Stream<Item=(T, A), Error=io::Error> + 'static
|
||||
pub fn start_incoming<S>(mut self, stream: S, secure: bool) -> io::Result<SyncAddress<Self>>
|
||||
where S: Stream<Item=(T, A), Error=io::Error> + 'static
|
||||
{
|
||||
if !self.sockets.is_empty() {
|
||||
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>,
|
||||
{
|
||||
/// Start listening for incomming tls connections.
|
||||
pub fn start_tls<Addr>(mut self, pkcs12: ::Pkcs12) -> io::Result<Addr>
|
||||
where Self: ActorAddress<Self, Addr>,
|
||||
{
|
||||
pub fn start_tls(mut self, pkcs12: ::Pkcs12) -> io::Result<SyncAddress<Self>> {
|
||||
if self.sockets.is_empty() {
|
||||
Err(io::Error::new(io::ErrorKind::Other, "No socket addresses are bound"))
|
||||
} else {
|
||||
|
@ -363,9 +360,7 @@ impl<H: HttpHandler, U, V> HttpServer<SslStream<TcpStream>, net::SocketAddr, H,
|
|||
/// Start listening for incomming tls connections.
|
||||
///
|
||||
/// This method sets alpn protocols to "h2" and "http/1.1"
|
||||
pub fn start_ssl<Addr>(mut self, identity: &ParsedPkcs12) -> io::Result<Addr>
|
||||
where Self: ActorAddress<Self, Addr>,
|
||||
{
|
||||
pub fn start_ssl(mut self, identity: &ParsedPkcs12) -> io::Result<SyncAddress<Self>> {
|
||||
if self.sockets.is_empty() {
|
||||
Err(io::Error::new(io::ErrorKind::Other, "No socket addresses are bound"))
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue