1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-28 01:32:57 +01:00

update examples

This commit is contained in:
Nikolay Kim 2017-12-07 18:08:16 -08:00
parent d595dd850e
commit 3f06439d3e
2 changed files with 4 additions and 4 deletions

View File

@ -30,11 +30,11 @@ fn main() {
let pkcs12 = Pkcs12::from_der(&pkcs12).unwrap().parse("12345").unwrap(); let pkcs12 = Pkcs12::from_der(&pkcs12).unwrap().parse("12345").unwrap();
HttpServer::new( HttpServer::new(
Application::default("/") Application::new("/")
// enable logger // enable logger
.middleware(middlewares::Logger::default()) .middleware(middlewares::Logger::default())
// register simple handler, handle all methods // register simple handler, handle all methods
.route("/index.html", |r| r.f(index)) .resource("/index.html", |r| r.f(index))
// with path parameters // with path parameters
.resource("/", |r| r.method(Method::GET).f(|req| { .resource("/", |r| r.method(Method::GET).f(|req| {
httpcodes::HTTPFound httpcodes::HTTPFound

View File

@ -197,7 +197,7 @@ fn main() {
// Create Http server with websocket support // Create Http server with websocket support
HttpServer::new( HttpServer::new(
Application::build("/", state) 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 +208,7 @@ fn main() {
// websocket // websocket
.resource("/ws/", |r| r.route().f(chat_route)) .resource("/ws/", |r| r.route().f(chat_route))
// static resources // static resources
.route("/static", |r| r.h(fs::StaticFiles::new("static/", true)))) .resource("/static", |r| r.h(fs::StaticFiles::new("static/", true))))
.serve::<_, ()>("127.0.0.1:8080").unwrap(); .serve::<_, ()>("127.0.0.1:8080").unwrap();
let _ = sys.run(); let _ = sys.run();