Decide on a Response Envelope
Added 2026-10
Decide on a Response Envelope — Chinese original prompt
现有接口统一返回 [包装结构],导致文件下载、第三方回调、HTTP 状态码的语义都被压平。请评估这层包装的收益与代价,给出保留、去掉或分场景使用的建议。输出:包装层带来的具体问题清单、三种方案的影响范围、迁移期间新老格式共存的处理、以及前端的兼容写法。
Site original
Chinese original
Example
Sample input
接口统一包一层 code、data、message,结果文件下载和回调也被包住,帮我判断留不留。
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.