Skip to content

How to limit body length only given http path? #2243

Answered by davidpdrsn
doowonee asked this question in Q&A
Discussion options

You must be logged in to vote

In my case only start with /upload path handler limit 50mb and rest of it like /user hanlders limit default as 2mb is it possible?

Yes that's possible. Just only add the middleware where you need it

Router::new()
    .route(
        "/upload",
        post(upload).layer(DefaultBodyLimit::max(52_428_800)),
    )
    .route("/other-route", get(foobar));

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@doowonee
Comment options

@davidpdrsn
Comment options

Answer selected by doowonee
@doowonee
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants