Skip to content

Commit

Permalink
fix(route): Add fullPath in context copy (#3784)
Browse files Browse the repository at this point in the history
* fix: Add fullPath in context copy

* Update context.go

---------

Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
  • Loading branch information
KarthikReddyPuli and appleboy authored Mar 6, 2024
1 parent f75144a commit 09f8224
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 @@ -120,6 +120,7 @@ func (c *Context) Copy() *Context {
cp.Writer = &cp.writermem
cp.index = abortIndex
cp.handlers = nil
cp.fullPath = c.fullPath

cKeys := c.Keys
cp.Keys = make(map[string]any, len(cKeys))
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 09f8224

Please sign in to comment.