fix(context): added warning for multiple writes to response body

warning works only in debug mode
This commit is contained in:
Raju Ahmed 2025-12-28 16:48:25 +06:00
parent 26c3a62865
commit 8eb015d2bc

View File

@ -1132,6 +1132,15 @@ func (c *Context) Render(code int, r render.Render) {
return
}
if c.Writer.Written() && IsDebugging() {
// Skip warning for SSE and streaming responses (status code -1)
if code != -1 {
if _, ok := r.(sse.Event); !ok {
debugPrint("[WARNING] Response body already written. Attempting to write again with status code %d", code)
}
}
}
if err := r.Render(c.Writer); err != nil {
// Pushing error to c.Errors
_ = c.Error(err)