Skip to content

docs(middleware): 修正 Next 与 Abort 的执行语义说明 - #424

Open
onewesong wants to merge 1 commit into
gin-gonic:masterfrom
onewesong:wws/fix-middleware-next-docs
Open

onewesong wants to merge 1 commit into
gin-gonic:masterfrom
onewesong:wws/fix-middleware-next-docs

Conversation

@onewesong

Copy link
Copy Markdown

问题与修正

“Using middleware” 页面错误地说明:未调用 c.Next() 会跳过后续中间件和 handler。实际行为是,只要上下文未被中止,当前中间件返回后,Gin 仍会继续执行处理链。这会误导鉴权中间件的实现。

本次同步修正全部 12 个语言版本的执行顺序说明:

  • 明确未调用 c.Next() 仍会执行后续处理链。
  • 说明 c.Next() 可用于在后续处理完成后执行收尾代码,并限定 LIFO 描述适用的情形。
  • 说明 c.Abort() / AbortWithStatus* 会跳过尚未执行的处理函数,但不会终止当前函数;需要时应配合 return。

Fixes #423

验证

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

文档错误:未调用 c.Next() 不会跳过后续中间件和 handler

1 participant