From 5a05a61647cc4ebd9bb7f1e3c978cc2d2ad5406a Mon Sep 17 00:00:00 2001 From: tamakyi Date: Thu, 29 Oct 2026 17:19:26 +0800 Subject: [PATCH] =?UTF-8?q?docs(api):=20=E8=AF=B4=E6=98=8E=20ask-status=20?= =?UTF-8?q?=E7=9A=84=20Method=20=E6=A3=80=E6=9F=A5=E6=98=AF=E9=98=B2?= =?UTF-8?q?=E5=BE=A1=E8=80=8C=E9=9D=9E=E4=B8=BB=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 路由只注册了 POST(token 不能进 URL),所以 GET 会落到 NotFound 返回 404, handler 里的 405 分支实际走不到。留着是为了将来路由若改成 f.Any 时仍然安全, 加上说明避免被当成死代码删掉。 --- route/question/ask_history.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/route/question/ask_history.go b/route/question/ask_history.go index 2acdd3f..2bdc083 100644 --- a/route/question/ask_history.go +++ b/route/question/ask_history.go @@ -68,6 +68,8 @@ func askExcerpt(content string) string { // 「某箱主有多少提问」「某个 id 是否存在」—— 错误的组合一律 ok=false, // 与「提问不存在」「不属于该箱主」「token 不对」三种情况无法区分。 func AskStatusAPI(ctx context.Context) error { + // 路由只注册了 POST(token 不能进 URL),这段是防御:万一将来有人把 + // 路由改成 f.Any / f.Combo,GET 也不该走到解析 body 那一步。 if ctx.Request().Method != http.MethodPost { return ctx.JSONError(40500, http.StatusText(http.StatusMethodNotAllowed)) }