Make request body size Limit configurable in juniper_rocket (#1044)

This commit is contained in:
Filip Gospodinov 2022-03-29 12:12:28 +02:00 committed by GitHub
parent 4182a8cf2b
commit 1fa69ebcfa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View file

@ -2,6 +2,7 @@
- Compatibility with the latest `juniper`. - Compatibility with the latest `juniper`.
- Provide `AsRef` and `AsMut` implementation for `GraphQLRequest` to its inner type ([#968](https://github.com/graphql-rust/juniper/pull/968), [#930](https://github.com/graphql-rust/juniper/issues/930)). - Provide `AsRef` and `AsMut` implementation for `GraphQLRequest` to its inner type ([#968](https://github.com/graphql-rust/juniper/pull/968), [#930](https://github.com/graphql-rust/juniper/issues/930)).
- Ability to set custom request body size limit ([#1044](https://github.com/graphql-rust/juniper/pull/1044)).
# [[0.8.0] 2021-07-08](https://github.com/graphql-rust/juniper/releases/tag/juniper_rocket-0.8.0) # [[0.8.0] 2021-07-08](https://github.com/graphql-rust/juniper/releases/tag/juniper_rocket-0.8.0)

View file

@ -349,8 +349,9 @@ where
}; };
Box::pin(async move { Box::pin(async move {
let limit = req.limits().get("graphql").unwrap_or(BODY_LIMIT.bytes());
let mut reader = data.open(limit);
let mut body = String::new(); let mut body = String::new();
let mut reader = data.open(BODY_LIMIT.bytes());
if let Err(e) = reader.read_to_string(&mut body).await { if let Err(e) = reader.read_to_string(&mut body).await {
return Failure((Status::InternalServerError, format!("{:?}", e))); return Failure((Status::InternalServerError, format!("{:?}", e)));
} }