From 74d0656d27e6afd87c6a0b805eb88e581410fb38 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 1 Apr 2018 18:24:07 -0700 Subject: [PATCH] update diesel example --- examples/diesel/src/main.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/diesel/src/main.rs b/examples/diesel/src/main.rs index d52a6192a..b821e9ffa 100644 --- a/examples/diesel/src/main.rs +++ b/examples/diesel/src/main.rs @@ -19,8 +19,8 @@ extern crate actix_web; extern crate env_logger; use actix::prelude::*; -use actix_web::{http, middleware, - App, HttpServer, HttpRequest, HttpResponse, Error, AsyncResponder}; +use actix_web::{http, server, middleware, + App, Path, State, HttpResponse, AsyncResponder, FutureResponse}; use diesel::prelude::*; use r2d2_diesel::ConnectionManager; @@ -34,12 +34,12 @@ use db::{CreateUser, DbExecutor}; /// State with DbExecutor address -struct App { +struct AppState { db: Addr, } /// Async request handler -fn index(name: Path<(String,)>, state: State) -> FutureResponse { +fn index(name: Path, state: State) -> FutureResponse { // send async `CreateUser` message to a `DbExecutor` state.db.send(CreateUser{name: name.into_inner()}) .from_err() @@ -66,8 +66,8 @@ fn main() { }); // Start http server - let _addr = HttpServer::new(move || { - App::with_state(State{db: addr.clone()}) + server::new(move || { + App::with_state(AppState{db: addr.clone()}) // enable logger .middleware(middleware::Logger::default()) .resource("/{name}", |r| r.method(http::Method::GET).with2(index))})