Files
2025-12-15 10:39:13 +08:00

34 lines
878 B
Go

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
}
// AuthorizationResponse represents the response from the authorization microservice
type AuthorizationResponse struct {
Allowed bool `json:"allowed"`
RedirectRoute string `json:"redirect_route,omitempty"`
Message string `json:"message,omitempty"`
}