docs(api): 说明 ask-status 的 Method 检查是防御而非主路径
路由只注册了 POST(token 不能进 URL),所以 GET 会落到 NotFound 返回 404, handler 里的 405 分支实际走不到。留着是为了将来路由若改成 f.Any 时仍然安全, 加上说明避免被当成死代码删掉。
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user