Files
web/mw/status_recorder.go
T

17 lines
441 B
Go
Raw Normal View History

package mw
import "net/http"
// StatusRecorder wraps http.ResponseWriter to capture the written status code.
// Used by [RequestLogger] to log the response status after the handler returns.
type StatusRecorder struct {
http.ResponseWriter
Status int
}
// WriteHeader captures the status code and delegates to the underlying writer.
func (r *StatusRecorder) WriteHeader(code int) {
r.Status = code
r.ResponseWriter.WriteHeader(code)
}