withcoderesponsewriter.go 405 B

123456789101112131415161718192021
  1. package security
  2. import "net/http"
  3. type WithCodeResponseWriter struct {
  4. Writer http.ResponseWriter
  5. Code int
  6. }
  7. func (w *WithCodeResponseWriter) Header() http.Header {
  8. return w.Writer.Header()
  9. }
  10. func (w *WithCodeResponseWriter) Write(bytes []byte) (int, error) {
  11. return w.Writer.Write(bytes)
  12. }
  13. func (w *WithCodeResponseWriter) WriteHeader(code int) {
  14. w.Writer.WriteHeader(code)
  15. w.Code = code
  16. }