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

fix example

This commit is contained in:
Nikolay Kim 2017-12-13 17:28:16 -08:00
parent 96f598f2c4
commit 653b431895

View File

@ -192,12 +192,14 @@ fn main() {
Ok(()) Ok(())
})); }));
// Websocket sessions state
let state = WsChatSessionState { addr: server };
// Create Http server with websocket support // Create Http server with websocket support
HttpServer::new( HttpServer::new(
Application::with_state("/", state) move || {
// Websocket sessions state
let state = WsChatSessionState { addr: server.clone() };
Application::with_state(state)
// redirect to websocket.html // redirect to websocket.html
.resource("/", |r| r.method(Method::GET).f(|req| { .resource("/", |r| r.method(Method::GET).f(|req| {
httpcodes::HTTPFound httpcodes::HTTPFound
@ -208,7 +210,9 @@ fn main() {
// websocket // websocket
.resource("/ws/", |r| r.route().f(chat_route)) .resource("/ws/", |r| r.route().f(chat_route))
// static resources // static resources
.resource("/static", |r| r.h(fs::StaticFiles::new("static/", true)))) .resource("/static/{tail:.*}",
|r| r.h(fs::StaticFiles::new("tail", "static/", true)))
})
.serve::<_, ()>("127.0.0.1:8080").unwrap(); .serve::<_, ()>("127.0.0.1:8080").unwrap();
let _ = sys.run(); let _ = sys.run();