mirror of
https://github.com/safing/portbase
synced 2025-09-01 18:19:57 +00:00
25 lines
587 B
Go
25 lines
587 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
// EnrichedResponseWriter is a wrapper for http.ResponseWriter for better information extraction.
|
|
type EnrichedResponseWriter struct {
|
|
http.ResponseWriter
|
|
Status int
|
|
}
|
|
|
|
// NewEnrichedResponseWriter wraps a http.ResponseWriter.
|
|
func NewEnrichedResponseWriter(w http.ResponseWriter) *EnrichedResponseWriter {
|
|
return &EnrichedResponseWriter{
|
|
w,
|
|
0,
|
|
}
|
|
}
|
|
|
|
// WriteHeader wraps the original WriteHeader method to extract information.
|
|
func (ew *EnrichedResponseWriter) WriteHeader(code int) {
|
|
ew.Status = code
|
|
ew.ResponseWriter.WriteHeader(code)
|
|
}
|