Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,13 +479,9 @@ func (c *Context) json(code int, i any, indent string) error {
// as JSONSerializer.Serialize can fail, and in that case we need to delay sending status code to the client until
// (global) error handler decides correct status code for the error to be sent to the client.
// For that we need to use writer that can store the proposed status code until the first Write is called.
if r, err := UnwrapResponse(c.response); err == nil {
r.Status = code
} else {
resp := c.Response()
c.SetResponse(&delayedStatusWriter{ResponseWriter: resp, status: code})
defer c.SetResponse(resp)
}
resp := c.Response()
c.SetResponse(&delayedStatusWriter{ResponseWriter: resp, status: code})
defer c.SetResponse(resp)

return c.echo.JSONSerializer.Serialize(c, i, indent)
}
Expand Down
Loading