Skip to content

Commit

Permalink
fix: Add fullPath in context copy
Browse files Browse the repository at this point in the history
  • Loading branch information
KarthikReddyPuli committed Nov 27, 2023
1 parent 44d0dd7 commit f8a04b6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func (c *Context) Copy() *Context {
paramCopy := make([]Param, len(cp.Params))
copy(paramCopy, cp.Params)
cp.Params = paramCopy
cp.fullPath = c.fullPath
return &cp
}

Expand Down
2 changes: 2 additions & 0 deletions context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ func TestContextCopy(t *testing.T) {
c.handlers = HandlersChain{func(c *Context) {}}
c.Params = Params{Param{Key: "foo", Value: "bar"}}
c.Set("foo", "bar")
c.fullPath = "/hola"

cp := c.Copy()
assert.Nil(t, cp.handlers)
Expand All @@ -336,6 +337,7 @@ func TestContextCopy(t *testing.T) {
assert.Equal(t, cp.Params, c.Params)
cp.Set("foo", "notBar")
assert.False(t, cp.Keys["foo"] == c.Keys["foo"])
assert.Equal(t, cp.fullPath, c.fullPath)
}

func TestContextHandlerName(t *testing.T) {
Expand Down

0 comments on commit f8a04b6

Please sign in to comment.