Qikuyueser.com

Define Rate-Limit Responses

Added 2026-10

Define Rate-Limit Responses — Chinese original prompt

接口 [接口名] 被限流时目前只返回一个 429,没有告诉客户端等多久、额度还剩多少。请定一套限流响应约定:状态码与响应体、剩余额度与重置时间的响应头、不同限流维度(用户、IP、应用)的表达,以及客户端应有的退避行为。输出:约定文档、服务端实现要点、给接入方的示例与建议。
Site original

Chinese original

Open in ChatGPT

Example

Sample input

下单接口被限流只返一个 429,没告诉客户端等多久,补齐响应头与语义约定。

The output should include

  • 给出状态码与响应体的结构
  • 剩余额度与重置时间的响应头
  • 说清不同限流维度与退避行为

Replace these placeholders 1

Swap the bracketed parts for your own details before sending.

  • [接口名]
How to use

响应头的重置时间基于服务端时钟,要一并返回当前时间或改用相对秒数。

Try tweaking it

  • Have it restate requirements and constraints before writing code.
  • Ask for the smallest change plus a rollback path, not a full-file rewrite.

What you should get

  • A minimal, runnable change with copy-ready code
  • Impact list: which files and call sites must follow

Common mistakes

  • Asking it to touch ten files at once, then losing track of what broke what.
  • Pasting only the error, with no code or version, and getting an unfixable answer.

How to check the output

  • The change runs, can be rolled back, and touches nothing unrelated.
  • Edge cases (empty, oversized, concurrent) are covered or explained.

Where it works

  • Good for: having it restate requirements and constraints, then propose the smallest runnable change.
  • Watch out: include versions and a minimal reproduction with the error, or the fix may look plausible but not fit.

More in this topic