tower-rs / tower-rs/tower-http

RequestBodyLimit custom response

Open
#417 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-feature-request T-middleware
Dominant language
Rust
Stars
913
Forks
231
Avg merge
1d 20h
Merged PRs (30d)
8

Description

Feature Request

Make it possible to define the response RequestBodyLimit gives when limits are exceed.

Motivation

User facing endpoints that accept large bodies should return a response that users can understand, possibly with some tips to solve request issues. The most basic tip being "what is the limit?".

Proposal

I think it could be done either via:

  • accepting a Fn() -> Response<B> in, or
  • returning a BoxError
Alternatives

The only alternative I can think of for now is to have another layer that checks if the response status is 413, and change the response body there.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the RequestBodyLimit implementation and reading how it currently produces the response when a request exceeds the limit. Compare the proposed callback and BoxError approaches, then confirm the intended API and response behavior with maintainers; done means callers can provide an understandable custom response for exceeded limits.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.