Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically handle
http_body::LengthLimitError
This adds special handling of `http_body::LengthLimitError` to `FailedToBufferBody` such that this just works and returns `413 Payload Too Large` if the limit is exceeded: ```rust use http_body::Limited; use tower_http::map_request_body::MapRequestBodyLayer; Router::new() .route("/", post(|body: Bytes| { ... })) .layer(MapRequestBodyLayer::new(|body| { Limited::new(body, 1024) })); ``` This is a draft until tower-rs/tower-http#271 is merged because I wanna make sure that works as well. The use case I have in mind is: ```rust use http_body::Limited; use tower_http::limit::RequestBodyLimitLayer; Router::new() .route("/", post(|body: Bytes| { ... })) .layer(RequestBodyLimitLayer::new(1024)); ```
- Loading branch information
1 parent
1d7878c
commit b8b4506
Showing
3 changed files
with
73 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters