mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 05:16:35 +08:00
fix: Add fullPath in context copy
This commit is contained in:
parent
44d0dd7092
commit
f8a04b6edb
@ -127,6 +127,7 @@ func (c *Context) Copy() *Context {
|
|||||||
paramCopy := make([]Param, len(cp.Params))
|
paramCopy := make([]Param, len(cp.Params))
|
||||||
copy(paramCopy, cp.Params)
|
copy(paramCopy, cp.Params)
|
||||||
cp.Params = paramCopy
|
cp.Params = paramCopy
|
||||||
|
cp.fullPath = c.fullPath
|
||||||
return &cp
|
return &cp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,6 +324,7 @@ func TestContextCopy(t *testing.T) {
|
|||||||
c.handlers = HandlersChain{func(c *Context) {}}
|
c.handlers = HandlersChain{func(c *Context) {}}
|
||||||
c.Params = Params{Param{Key: "foo", Value: "bar"}}
|
c.Params = Params{Param{Key: "foo", Value: "bar"}}
|
||||||
c.Set("foo", "bar")
|
c.Set("foo", "bar")
|
||||||
|
c.fullPath = "/hola"
|
||||||
|
|
||||||
cp := c.Copy()
|
cp := c.Copy()
|
||||||
assert.Nil(t, cp.handlers)
|
assert.Nil(t, cp.handlers)
|
||||||
@ -336,6 +337,7 @@ func TestContextCopy(t *testing.T) {
|
|||||||
assert.Equal(t, cp.Params, c.Params)
|
assert.Equal(t, cp.Params, c.Params)
|
||||||
cp.Set("foo", "notBar")
|
cp.Set("foo", "notBar")
|
||||||
assert.False(t, cp.Keys["foo"] == c.Keys["foo"])
|
assert.False(t, cp.Keys["foo"] == c.Keys["foo"])
|
||||||
|
assert.Equal(t, cp.fullPath, c.fullPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestContextHandlerName(t *testing.T) {
|
func TestContextHandlerName(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user