mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-27 12:28:40 +08:00
e97e1f10db
* simplify code with http.Flusher type conversion * simplify code with http.Flusher type conversion, better version
28 lines
521 B
Go
28 lines
521 B
Go
package security
|
|
|
|
import "net/http"
|
|
|
|
type WithCodeResponseWriter struct {
|
|
Writer http.ResponseWriter
|
|
Code int
|
|
}
|
|
|
|
func (w *WithCodeResponseWriter) Flush() {
|
|
if flusher, ok := w.Writer.(http.Flusher); ok {
|
|
flusher.Flush()
|
|
}
|
|
}
|
|
|
|
func (w *WithCodeResponseWriter) Header() http.Header {
|
|
return w.Writer.Header()
|
|
}
|
|
|
|
func (w *WithCodeResponseWriter) Write(bytes []byte) (int, error) {
|
|
return w.Writer.Write(bytes)
|
|
}
|
|
|
|
func (w *WithCodeResponseWriter) WriteHeader(code int) {
|
|
w.Writer.WriteHeader(code)
|
|
w.Code = code
|
|
}
|