package models

import "net/http"

// FlusherPreservingResponseWriter wraps http.ResponseWriter and preserves http.Flusher for SSE endpoints.
type FlusherPreservingResponseWriter struct {
	http.ResponseWriter
}

func (w *FlusherPreservingResponseWriter) Flush() {
	if f, ok := w.ResponseWriter.(http.Flusher); ok {
		f.Flush()
	}
}

// ResponseWriter wraps http.ResponseWriter to track response size for metrics
type ResponseWriter struct {
	http.ResponseWriter
	Size int
}

func (rw *ResponseWriter) Write(b []byte) (int, error) {
	size, err := rw.ResponseWriter.Write(b)
	rw.Size += size
	return size, err
}
