vault backup: 2026-04-28 08:53:28
This commit is contained in:
@@ -9,7 +9,8 @@ create time: 2026-04-27 00:00
|
||||
|
||||
Gin 的 `*gin.Context` 是每次请求的核心载体——它封装了 Request、ResponseWriter、参数、JSON 绑定、中间件链和错误处理。理解 Context 的完整生命周期,是从"会用 Gin"进阶到"写对 Gin"的关键一步。
|
||||
|
||||
思考题:Gin 用 `sync.Pool` 复用 Context 对象,这意味着你**不能**在 handler 返回后继续使用 Context,对吗?为什么?
|
||||
思考题:Gin 用 `sync.Pool` 复用 Context 对象,这意味着你**不能**在 handler 返回后继续使用 Context,对吗?为什么?
|
||||
详见 → [[4-context-lifecycle/context-pool-safety]]
|
||||
|
||||
## 正文
|
||||
|
||||
@@ -224,3 +225,4 @@ Gin 默认**不设置**读取超时。如果需要超时控制,应在 `http.Se
|
||||
- [[GIN/1-gin-architecture]] — Engine 初始化与 Context 池化
|
||||
- [[GIN/3-middleware]] — 中间件深入实践
|
||||
- [[GIN/5-binding-validation]] — 模型绑定与校验
|
||||
- [[4-context-lifecycle/context-pool-safety]] — sync.Pool 复用安全:handler 返回后为什么不能持有 Context
|
||||
|
||||
Reference in New Issue
Block a user