最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - How to customize the "413 Payload Too Large" response in Quarkus with multipartform-data requests? - St

programmeradmin0浏览0评论

How to customize the "413 Payload Too Large" response in Quarkus with multipart/form-data requests?

I'm working with a Java 21 Quarkus (3.18.1) API that uses the quarkus.http.limits.max-form-attribute-size property to limit request body size. When a request body exceeds this limit, the application automatically responds with a "413 Payload Too Large" error.

I want to customize this response to return a custom JSON payload that maintains a consistent response schema across my application.

The HTTP requests to my API use multipart/form-data with both text fields and file uploads. For example:

curl --request POST \
  --url http://localhost:8080/api \
  --header 'content-type: multipart/form-data' \
  --form 'text=content' \
  --form 'document=@C:\path\to\file.pdf'

How can I intercept and customize the "413 Payload Too Large" response for these multipart requests?

Any suggestions about the best approach to handle this would be appreciated.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论