Skip to content

Commit fa92d92

Browse files
committed
Update actix-web
1 parent 6f44e54 commit fa92d92

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

wundergraph_bench/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ authors = ["Georg Semmler <[email protected]>"]
77
wundergraph = {path = "../wundergraph", default-features = false, features = ["postgres", "chrono"]}
88
diesel = {version = "=1.2.2", features = ["r2d2", "sqlite", "chrono", "postgres"]}
99
juniper = "=0.9.2"
10-
actix = "0.5"
11-
actix-web = "0.6"
10+
actix = "0.7"
11+
actix-web = "0.7"
1212
failure = "0.1"
1313
serde = {version = "1", features = ["derive"]}
1414
serde_json = "1"

wundergraph_bench/src/main.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extern crate futures;
3636
extern crate num_cpus;
3737
extern crate serde_json;
3838

39-
use actix::{Actor, Addr, Handler, Message, Syn, SyncArbiter, SyncContext};
39+
use actix::{Actor, Addr, Handler, Message, SyncArbiter, SyncContext};
4040
use actix_web::{
4141
http, server, App, AsyncResponder, FutureResponse, HttpRequest, HttpResponse, Json, State,
4242
};
@@ -97,26 +97,28 @@ impl Handler<GraphQLData> for GraphQLExecutor {
9797
}
9898

9999
struct AppState {
100-
executor: Addr<Syn, GraphQLExecutor>,
100+
executor: Addr<GraphQLExecutor>,
101101
}
102102

103103
#[cfg_attr(feature = "clippy", allow(needless_pass_by_value))]
104-
fn graphiql(_req: HttpRequest<AppState>) -> Result<HttpResponse, Error> {
104+
fn graphiql(_req: &HttpRequest<AppState>) -> Result<HttpResponse, Error> {
105105
let html = graphiql_source("/graphql");
106106
Ok(HttpResponse::Ok()
107107
.content_type("text/html; charset=utf-8")
108108
.body(html))
109109
}
110110

111111
#[cfg_attr(feature = "clippy", allow(needless_pass_by_value))]
112-
fn graphql(st: State<AppState>, data: Json<GraphQLData>) -> FutureResponse<HttpResponse> {
112+
fn graphql(
113+
(st, data): (State<AppState>, Json<GraphQLData>),
114+
) -> FutureResponse<HttpResponse> {
113115
st.executor
114116
.send(data.0)
115117
.from_err()
116118
.and_then(|res| match res {
117-
Ok(res) => Ok(HttpResponse::Ok()
119+
Ok(user) => Ok(HttpResponse::Ok()
118120
.content_type("application/json")
119-
.body(res)),
121+
.body(user)),
120122
Err(_) => Ok(HttpResponse::InternalServerError().into()),
121123
})
122124
.responder()
@@ -151,8 +153,8 @@ fn main() {
151153
App::with_state(AppState{executor: addr.clone()})
152154
// enable logger
153155
// .middleware(middleware::Logger::default())
154-
.resource("/graphql", |r| r.method(http::Method::POST).with2(graphql))
155-
.resource("/graphql", |r| r.method(http::Method::GET).with2(graphql))
156+
.resource("/graphql", |r| r.method(http::Method::POST).with(graphql))
157+
.resource("/graphql", |r| r.method(http::Method::GET).with(graphql))
156158
.resource("/graphiql", |r| r.method(http::Method::GET).h(graphiql))
157159
.default_resource(|r| r.get().f(|_| HttpResponse::Found().header("location", "/graphiql").finish()))
158160
}).workers(num_cpus::get() * 2)

wundergraph_example/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ license = "MIT OR Apache-2.0"
88
diesel = { version = "=1.2.2", features = ["r2d2", "sqlite", "chrono", "postgres"]}
99
diesel_migrations = "=1.2.0"
1010
juniper = "=0.9.2"
11-
actix = "0.5"
12-
actix-web = "0.6"
11+
actix = "0.7"
12+
actix-web = "0.7"
1313
indexmap = "1"
1414
clippy = { version = "0.0.207", optional = true }
1515
failure = "0.1"

wundergraph_example/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,19 +367,19 @@ impl Handler<GraphQLData> for GraphQLExecutor {
367367
}
368368

369369
struct AppState {
370-
executor: Addr<Syn, GraphQLExecutor>,
370+
executor: Addr<GraphQLExecutor>,
371371
}
372372

373373
#[cfg_attr(feature = "clippy", allow(needless_pass_by_value))]
374-
fn graphiql(_req: HttpRequest<AppState>) -> Result<HttpResponse, Error> {
374+
fn graphiql(_req: &HttpRequest<AppState>) -> Result<HttpResponse, Error> {
375375
let html = graphiql_source("/graphql");
376376
Ok(HttpResponse::Ok()
377377
.content_type("text/html; charset=utf-8")
378378
.body(html))
379379
}
380380

381381
#[cfg_attr(feature = "clippy", allow(needless_pass_by_value))]
382-
fn graphql(st: State<AppState>, data: Json<GraphQLData>) -> FutureResponse<HttpResponse> {
382+
fn graphql((st, data): (State<AppState>, Json<GraphQLData>)) -> FutureResponse<HttpResponse> {
383383
st.executor
384384
.send(data.0)
385385
.from_err()
@@ -426,8 +426,8 @@ fn main() {
426426
App::with_state(AppState{executor: addr.clone()})
427427
// enable logger
428428
.middleware(middleware::Logger::default())
429-
.resource("/graphql", |r| r.method(http::Method::POST).with2(graphql))
430-
.resource("/graphql", |r| r.method(http::Method::GET).with2(graphql))
429+
.resource("/graphql", |r| r.method(http::Method::POST).with(graphql))
430+
.resource("/graphql", |r| r.method(http::Method::GET).with(graphql))
431431
.resource("/graphiql", |r| r.method(http::Method::GET).h(graphiql))
432432
.default_resource(|r| r.get().f(|_| HttpResponse::Found().header("location", "/graphiql").finish()))
433433
}).bind("127.0.0.1:8000")

0 commit comments

Comments
 (0)