Fix

"http: wrote more than the declared Content-Length"

Web
Fix the 'http: wrote more than the declared Content-Length' error by ensuring your response body size matches the Content-Length header.

The "http: wrote more than the declared Content-Length" error occurs when your HTTP server sends more bytes than the Content-Length header declares, causing the client to abort the connection. Ensure your handler writes exactly the number of bytes specified in the header or uses http.Flush() if streaming data of unknown length.

// Ensure Content-Length matches actual body size
w.Header().Set("Content-Length", fmt.Sprintf("%d", len(body)))
w.Write(body)