Update to latest Rocket on master
(#699)
The `async` branch has now landed on Rocket's `master`. The git branch has been deleted.
This commit is contained in:
parent
61a5a747f1
commit
3616e36ece
2 changed files with 10 additions and 8 deletions
|
@ -15,7 +15,7 @@ edition = "2018"
|
|||
serde_json = { version = "1.0.2" }
|
||||
juniper = { version = "0.14.2", default-features = false, path = "../juniper" }
|
||||
futures = { version = "0.3.1", features = ["compat"] }
|
||||
rocket = { git = "https://github.com/SergioBenitez/Rocket", branch = "async", default-features = false }
|
||||
rocket = { git = "https://github.com/SergioBenitez/Rocket", branch = "master", default-features = false }
|
||||
tokio = { version = "0.2", features = ["rt-core", "macros"] }
|
||||
|
||||
[dev-dependencies.juniper]
|
||||
|
|
|
@ -42,7 +42,7 @@ Check the LICENSE file for details.
|
|||
use std::io::Cursor;
|
||||
|
||||
use rocket::{
|
||||
data::{FromDataFuture, FromDataSimple},
|
||||
data::{self, FromData},
|
||||
http::{ContentType, RawStr, Status},
|
||||
request::{FormItems, FromForm, FromFormValue},
|
||||
response::{self, content, Responder, Response},
|
||||
|
@ -288,13 +288,14 @@ where
|
|||
|
||||
const BODY_LIMIT: u64 = 1024 * 100;
|
||||
|
||||
impl<S> FromDataSimple for GraphQLRequest<S>
|
||||
#[rocket::async_trait]
|
||||
impl<S> FromData for GraphQLRequest<S>
|
||||
where
|
||||
S: ScalarValue,
|
||||
{
|
||||
type Error = String;
|
||||
|
||||
fn from_data(req: &Request, data: Data) -> FromDataFuture<'static, Self, Self::Error> {
|
||||
async fn from_data(req: &Request<'_>, data: Data) -> data::Outcome<Self, Self::Error> {
|
||||
use tokio::io::AsyncReadExt as _;
|
||||
|
||||
let content_type = req
|
||||
|
@ -303,7 +304,7 @@ where
|
|||
let is_json = match content_type {
|
||||
Some(("application", "json")) => true,
|
||||
Some(("application", "graphql")) => false,
|
||||
_ => return Box::pin(async move { Forward(data) }),
|
||||
_ => return Box::pin(async move { Forward(data) }).await,
|
||||
};
|
||||
|
||||
Box::pin(async move {
|
||||
|
@ -322,6 +323,7 @@ where
|
|||
GraphQLBatchRequest::Single(http::GraphQLRequest::new(body, None, None))
|
||||
}))
|
||||
})
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -464,7 +466,7 @@ mod tests {
|
|||
use rocket::{
|
||||
self, get,
|
||||
http::ContentType,
|
||||
local::{Client, LocalResponse},
|
||||
local::asynchronous::{Client, LocalResponse},
|
||||
post,
|
||||
request::Form,
|
||||
routes, Rocket, State,
|
||||
|
@ -566,14 +568,14 @@ mod tests {
|
|||
))
|
||||
}
|
||||
|
||||
async fn make_test_response(mut response: LocalResponse<'_>) -> http_tests::TestResponse {
|
||||
async fn make_test_response(response: LocalResponse<'_>) -> http_tests::TestResponse {
|
||||
let status_code = response.status().code as i32;
|
||||
let content_type = response
|
||||
.content_type()
|
||||
.expect("No content type header from handler")
|
||||
.to_string();
|
||||
let body = response
|
||||
.body_string()
|
||||
.into_string()
|
||||
.await
|
||||
.expect("No body returned from GraphQL handler");
|
||||
|
||||
|
|
Loading…
Reference in a new issue