fix(engine): missing route params for CreateTestContext (#2778) (#2803)

This commit is contained in:
RoCry
2022-11-06 17:08:11 +08:00
committed by GitHub
parent 971fe21876
commit 55e27f1246
3 changed files with 27 additions and 5 deletions
+3 -3
View File
@@ -203,7 +203,7 @@ func New() *Engine {
}
engine.RouterGroup.engine = engine
engine.pool.New = func() any {
return engine.allocateContext()
return engine.allocateContext(engine.maxParams)
}
return engine
}
@@ -225,8 +225,8 @@ func (engine *Engine) Handler() http.Handler {
return h2c.NewHandler(engine, h2s)
}
func (engine *Engine) allocateContext() *Context {
v := make(Params, 0, engine.maxParams)
func (engine *Engine) allocateContext(maxParams uint16) *Context {
v := make(Params, 0, maxParams)
skippedNodes := make([]skippedNode, 0, engine.maxSections)
return &Context{engine: engine, params: &v, skippedNodes: &skippedNodes}
}