Skip to content

Commit

Permalink
fix: add full path copy (#1050)
Browse files Browse the repository at this point in the history
  • Loading branch information
li-jin-gou authored Jan 16, 2024
1 parent af5c263 commit 0d25abe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/app/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,7 @@ func (ctx *RequestContext) Copy() *RequestContext {
paramCopy := make([]param.Param, len(cp.Params))
copy(paramCopy, cp.Params)
cp.Params = paramCopy
cp.fullPath = ctx.fullPath
cp.clientIPFunc = ctx.clientIPFunc
cp.formValueFunc = ctx.formValueFunc
cp.binder = ctx.binder
Expand Down
6 changes: 6 additions & 0 deletions pkg/app/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ func TestGet(t *testing.T) {
func TestCopy(t *testing.T) {
t.Parallel()
ctx := NewContext(0)
ctx.fullPath = "full_path"
ctx.Request.Header.Add("header_a", "header_value_a")
ctx.Response.Header.Add("header_b", "header_value_b")
ctx.Params = param.Params{
Expand All @@ -244,6 +245,11 @@ func TestCopy(t *testing.T) {
return
}

if c.fullPath != "full_path" {
t.Errorf("unexpected value: %#v, expected: %#v", c.fullPath, "full_path")
return
}

reqHeaderStr := context.Request.Header.Get("header_a")
if reqHeaderStr != "header_value_a" {
t.Errorf("unexpected value: %#v, expected: %#v", reqHeaderStr, "header_value_a")
Expand Down

0 comments on commit 0d25abe

Please sign in to comment.