Browse Source

Move ResponseWriter

Volodymyr Tkach 2 years ago
parent
commit
6dd1b89584
2 changed files with 26 additions and 23 deletions
  1. 0 23
      utils/http/logger/logger.go
  2. 26 0
      utils/http/logger/writer.go

+ 0 - 23
utils/http/logger/logger.go

@@ -10,29 +10,6 @@ import (
 	"github.com/vladimirok5959/golang-utils/utils/http/helpers"
 )
 
-type ResponseWriter struct {
-	http.ResponseWriter
-	Content []byte
-	Size    int
-	Status  int
-}
-
-func (w *ResponseWriter) Write(b []byte) (int, error) {
-	if RollBarEnabled {
-		if !RollBarSkipStatusCodes.Contain(w.Status) {
-			w.Content = append(w.Content, b...)
-		}
-	}
-	size, err := w.ResponseWriter.Write(b)
-	w.Size += size
-	return size, err
-}
-
-func (w *ResponseWriter) WriteHeader(status int) {
-	w.Status = status
-	w.ResponseWriter.WriteHeader(status)
-}
-
 func LogInternalError(err error) {
 	log.Printf("%s\n", err.Error())
 	if RollBarEnabled {

+ 26 - 0
utils/http/logger/writer.go

@@ -0,0 +1,26 @@
+package logger
+
+import "net/http"
+
+type ResponseWriter struct {
+	http.ResponseWriter
+	Content []byte
+	Size    int
+	Status  int
+}
+
+func (w *ResponseWriter) Write(b []byte) (int, error) {
+	if RollBarEnabled {
+		if !RollBarSkipStatusCodes.Contain(w.Status) {
+			w.Content = append(w.Content, b...)
+		}
+	}
+	size, err := w.ResponseWriter.Write(b)
+	w.Size += size
+	return size, err
+}
+
+func (w *ResponseWriter) WriteHeader(status int) {
+	w.Status = status
+	w.ResponseWriter.WriteHeader(status)
+}