As I said in your last thread:
What you want is impossible, based on how HTTP works. The status of a request must be determined *before* any of the body is written. So, if writing the body fails, there is nothing more you can do - you can only ignore that. And it's not an abnormal condition for the writing of a body to fail, as clients may disconnect at any time.
The best you can do is
a) write the body to an in-memory buffer, to make sure all bytes that need to be written are correctly determined,
b) then set tany headers (e.g. content-type) and status as appropriate and
c) write out the body, ignoring any errors - or at best, increment a metric or logging it.
That is, IMO, the best you can do with HTTP. There is no guarantee the body can be written, before you try do it and you can't set the status after you start writing the body. But if the actual *Write* fails (as opposed to the Read part of an io.Copy) you can at least be reasonably sure that the problem is some network issue or client disconnect you can't do anything about, so it's fine to ignore (from an application perspective).