You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
403 B

  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. }