Bump actix-web from 4.0.0-beta.11 to 4.0.0-beta.14

This commit is contained in:
Sunli 2021-12-12 10:10:28 +08:00
parent 9cced48733
commit 23fd49a70b
5 changed files with 46 additions and 63 deletions

@ -1 +1 @@
Subproject commit ad5a253197dff977eadd7afb6626036776a162b7
Subproject commit f9116e9029f6d57cea22c139c3e5fd952b774979

View File

@ -14,9 +14,9 @@ categories = ["network-programming", "asynchronous"]
[dependencies]
async-graphql = { path = "../..", version = "3.0.13" }
actix = "0.12.0"
actix-http = "3.0.0-beta.12"
actix-web = { version = "4.0.0-beta.11", default-features = false }
actix-web-actors = "4.0.0-beta.7"
actix-http = "3.0.0-beta.15"
actix-web = { version = "4.0.0-beta.14", default-features = false }
actix-web-actors = "4.0.0-beta.8"
async-channel = "1.6.1"
futures-util = { version = "0.3.17", default-features = false }
serde_json = "1.0.64"

View File

@ -1,3 +1,4 @@
use actix_http::body::BoxBody;
use std::future::Future;
use std::io::{self, ErrorKind};
use std::pin::Pin;
@ -153,6 +154,8 @@ impl From<async_graphql::BatchResponse> for GraphQLResponse {
}
impl Responder for GraphQLResponse {
type Body = BoxBody;
fn respond_to(self, _req: &HttpRequest) -> HttpResponse {
let mut res = HttpResponse::build(StatusCode::OK);
res.content_type("application/json");

View File

@ -114,7 +114,9 @@ where
continuation: Vec::new(),
};
actix_web_actors::ws::start_with_protocols(actor, &ALL_WEBSOCKET_PROTOCOLS, request, stream)
actix_web_actors::ws::WsResponseBuilder::new(actor, request, stream)
.protocols(&ALL_WEBSOCKET_PROTOCOLS)
.start()
}
}

View File

@ -1,5 +1,5 @@
use actix_http::Method;
use actix_web::dev::{AnyBody, Service};
use actix_web::dev::Service;
use actix_web::{guard, test, web, web::Data, App};
use serde_json::json;
@ -21,12 +21,12 @@ async fn test_playground() {
let req = test::TestRequest::with_uri("/").to_request();
let response = srv.call(req).await.unwrap();
assert!(response.status().is_success());
let body = response.response().body();
if let AnyBody::Bytes(bytes) = body {
assert!(std::str::from_utf8(&bytes).unwrap().contains("graphql"));
} else {
panic!("response body must be Bytes {:?}", body);
}
let body = response.into_body();
assert!(
std::str::from_utf8(&actix_web::body::to_bytes(body).await.unwrap())
.unwrap()
.contains("graphql")
);
}
#[actix_rt::test]
@ -55,10 +55,10 @@ async fn test_add() {
.await
.unwrap();
assert!(response.status().is_success());
let body = response.response().body();
let body = response.into_body();
assert_eq!(
body,
&AnyBody::Bytes(json!({"data": {"add": 30}}).to_string().into_bytes().into())
actix_web::body::to_bytes(body).await.unwrap(),
json!({"data": {"add": 30}}).to_string().into_bytes()
);
}
@ -89,15 +89,12 @@ async fn test_hello() {
.await
.unwrap();
assert!(response.status().is_success());
let body = response.response().body();
let body = response.into_body();
assert_eq!(
body,
&AnyBody::Bytes(
json!({"data": {"hello": "Hello, world!"}})
.to_string()
.into_bytes()
.into()
)
actix_web::body::to_bytes(body).await.unwrap(),
json!({"data": {"hello": "Hello, world!"}})
.to_string()
.into_bytes()
);
}
@ -129,15 +126,12 @@ async fn test_hello_header() {
.await
.unwrap();
assert!(response.status().is_success());
let body = response.response().body();
let body = response.into_body();
assert_eq!(
body,
&AnyBody::Bytes(
json!({"data": {"hello": "Hello, Foo!"}})
.to_string()
.into_bytes()
.into()
)
actix_web::body::to_bytes(body).await.unwrap(),
json!({"data": {"hello": "Hello, Foo!"}})
.to_string()
.into_bytes()
);
}
@ -168,15 +162,10 @@ async fn test_count() {
.await
.unwrap();
assert!(response.status().is_success());
let body = response.response().body();
let body = response.into_body();
assert_eq!(
body,
&AnyBody::Bytes(
json!({"data": {"count": 0}})
.to_string()
.into_bytes()
.into()
)
actix_web::body::to_bytes(body).await.unwrap(),
json!({"data": {"count": 0}}).to_string().into_bytes()
);
let response = srv
@ -189,15 +178,10 @@ async fn test_count() {
.await
.unwrap();
assert!(response.status().is_success());
let body = response.response().body();
let body = response.into_body();
assert_eq!(
body,
&AnyBody::Bytes(
json!({"data": {"addCount": 10}})
.to_string()
.into_bytes()
.into()
)
actix_web::body::to_bytes(body).await.unwrap(),
json!({"data": {"addCount": 10}}).to_string().into_bytes(),
);
let response = srv
@ -210,15 +194,12 @@ async fn test_count() {
.await
.unwrap();
assert!(response.status().is_success());
let body = response.response().body();
let body = response.into_body();
assert_eq!(
body,
&AnyBody::Bytes(
json!({"data": {"subtractCount": 8}})
.to_string()
.into_bytes()
.into()
)
actix_web::body::to_bytes(body).await.unwrap(),
json!({"data": {"subtractCount": 8}})
.to_string()
.into_bytes()
);
let response = srv
@ -231,14 +212,11 @@ async fn test_count() {
.await
.unwrap();
assert!(response.status().is_success());
let body = response.response().body();
let body = response.into_body();
assert_eq!(
body,
&AnyBody::Bytes(
json!({"data": {"subtractCount": 6}})
.to_string()
.into_bytes()
.into()
)
actix_web::body::to_bytes(body).await.unwrap(),
json!({"data": {"subtractCount": 6}})
.to_string()
.into_bytes()
);
}