mirror of
https://github.com/infinite-iroha/touka.git
synced 2026-02-03 00:41:10 +08:00
fix limitMaxSizeReader non use body close & fix mergeCtx Value
This commit is contained in:
parent
cb86cb935a
commit
49508b49c1
2 changed files with 14 additions and 8 deletions
10
mergectx.go
10
mergectx.go
|
|
@ -69,15 +69,9 @@ func MergeCtx(parents ...context.Context) (ctx context.Context, cancel context.C
|
|||
return mc, mc.cancel
|
||||
}
|
||||
|
||||
// Value 实现了 context.Context 的 Value 方法.
|
||||
// 它会按顺序遍历所有父 context, 并返回第一个找到的非 nil 值.
|
||||
// Value 返回当前Ctx Value
|
||||
func (mc *mergedContext) Value(key any) any {
|
||||
for _, p := range mc.parents {
|
||||
if v := p.Value(key); v != nil {
|
||||
return v
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return mc.Context.Value(key)
|
||||
}
|
||||
|
||||
// Deadline 实现了 context.Context 的 Deadline 方法.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue