Skip to content

Commit 09f8224

Browse files
fix(route): Add fullPath in context copy (#3784)
* fix: Add fullPath in context copy * Update context.go --------- Co-authored-by: Bo-Yi Wu <[email protected]>
1 parent f75144a commit 09f8224

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

context.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ func (c *Context) Copy() *Context {
120120
cp.Writer = &cp.writermem
121121
cp.index = abortIndex
122122
cp.handlers = nil
123+
cp.fullPath = c.fullPath
123124

124125
cKeys := c.Keys
125126
cp.Keys = make(map[string]any, len(cKeys))

context_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ func TestContextCopy(t *testing.T) {
324324
c.handlers = HandlersChain{func(c *Context) {}}
325325
c.Params = Params{Param{Key: "foo", Value: "bar"}}
326326
c.Set("foo", "bar")
327+
c.fullPath = "/hola"
327328

328329
cp := c.Copy()
329330
assert.Nil(t, cp.handlers)
@@ -336,6 +337,7 @@ func TestContextCopy(t *testing.T) {
336337
assert.Equal(t, cp.Params, c.Params)
337338
cp.Set("foo", "notBar")
338339
assert.False(t, cp.Keys["foo"] == c.Keys["foo"])
340+
assert.Equal(t, cp.fullPath, c.fullPath)
339341
}
340342

341343
func TestContextHandlerName(t *testing.T) {

0 commit comments

Comments
 (0)