http_status_recorder.go 403 B

123456789101112131415161718192021
  1. package stats
  2. import "net/http"
  3. type StatusRecorder struct {
  4. http.ResponseWriter
  5. Status int
  6. }
  7. func NewStatusResponseWriter(w http.ResponseWriter) *StatusRecorder {
  8. return &StatusRecorder{w, http.StatusOK}
  9. }
  10. func (r *StatusRecorder) WriteHeader(status int) {
  11. r.Status = status
  12. r.ResponseWriter.WriteHeader(status)
  13. }
  14. func (r *StatusRecorder) Flush() {
  15. r.ResponseWriter.(http.Flusher).Flush()
  16. }