8000 Add `DefaultBodyLimit::apply` by SabrinaJewson · Pull Request #3368 · tokio-rs/axum · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add DefaultBodyLimit::apply #3368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2025

Conversation

SabrinaJewson
Copy link
Contributor
@SabrinaJewson SabrinaJewson commented Jun 1, 2025

Motivation

I am writing an extractor, and it would be useful to have that extractor change the default body limit. This can be done today with the following code:

let req = DefaultBodyLimit::max(1024)
	.layer(tower::service_fn(|req| async { Ok::<_, Infallible>(req) }))
	.call(req)
	.await
	.unwrap_or_else(|e| match e {});

But it would be nice to have a convenience method for this.

Solution

impl DefaultBodyLimit {
    fn apply<B>(self, req: &mut Request<B>);
}

@mladedav mladedav merged commit 8202c66 into tokio-rs:main Jun 3, 2025
18 checks passed
@SabrinaJewson SabrinaJewson deleted the defaultbodylimit-apply branch June 3, 2025 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0