feat: As a user, I want the `limit-*` plugins can return the `error_msg` directly, so that HTML or other kinds of response can be returned
- Dominant language
- Lua
- Stars
- 17.1k
- Forks
- 2.9k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 63
Description
### Description
Currently, the `limit-*` plugins support configuring an `error_msg` field to let users customize the error response when requests are throttled. However, Apache APISIX always puts the `error_msg` into a JSON string. It's not reasonable if users want to configure an HTML page. So, `limit-*` plugins should just return the `error_msg` without any wrapping. If a user wants to return a JSON string, just let this user configure this JSON string. So the same for HTML or others.
Of course, we may need another field to let users to configure the `Content-Type` so that the client can distinguish the response correctly.
https://github.com/apache/apisix/blob/4e25e5b4acc2e8293787b8861d0b4c2715cdc3af/apisix/plugins/limit-count/init.lua#L289-L293
Contributor guide
Research direction
Start with the linked limit-count plugin code at apisix/plugins/limit-count/init.lua#L289-L293 and compare how its error_msg response is currently produced. Trace the related limit-* plugin behavior and define completion as returning the configured message without JSON wrapping, with an appropriate Content-Type option for HTML or other response formats.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100