Skip to content

Commit

Permalink
Merge pull request #120 from hidevopsio/release-1.6
Browse files Browse the repository at this point in the history
fixes the issue that previous data response is being remained on resp…
  • Loading branch information
john-deng authored Oct 26, 2022
2 parents e974538 + 2dd1bac commit 43975c4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/app/web/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ func (h *handler) finalizeResponse(ctx context.Context) {
ctx.ResponseError(err.Error(), http.StatusInternalServerError)
}
}
// To clear current context and init for next request to prevent garbage response
ctx.InitResponses()
}
}
return
Expand Down Expand Up @@ -403,7 +405,6 @@ func (h *handler) responseWithError(ctx context.Context, numOut int, results []r
}
}


func (h *handler) setErrorResponseCode(ctx context.Context, response model.ResponseInfo) {
if response.GetCode() == 0 {
prevStatusCode := ctx.GetStatusCode()
Expand All @@ -426,7 +427,7 @@ func (h *handler) call(ctx context.Context) {
// init responses
log.Debugf("HTTP Handler: %v: %v %v%v", ctx.HandlerIndex(-1), ctx.Method(), ctx.Host(), ctx.Path())
idx := ctx.HandlerIndex(-1)
if idx <= 1 {
if idx <= 1 {
ctx.InitResponses()
}

Expand All @@ -442,7 +443,7 @@ func (h *handler) call(ctx context.Context) {
if h.numOut > 1 {
results[0] = reflect.New(h.responses[0].typ.Elem())
}
results[h.numOut - 1] = reflect.ValueOf(reqErr)
results[h.numOut-1] = reflect.ValueOf(reqErr)
}
}
if reqErr == nil {
Expand Down

0 comments on commit 43975c4

Please sign in to comment.