feat(backend): removed debug logs in http methods

This commit is contained in:
Alexander Zavorotynskiy 2023-04-11 14:08:42 +02:00 committed by Delirium
parent 2a9c64ef16
commit f465d16110
2 changed files with 6 additions and 13 deletions

View file

@ -38,7 +38,9 @@ func (e *Router) readBody(w http.ResponseWriter, r *http.Request, limit int64) (
if err != nil {
return nil, fmt.Errorf("can't read gzip body: %s", err)
}
reader.Close()
if err := reader.Close(); err != nil {
log.Printf("can't close gzip reader: %s", err)
}
// Debug log
log.Printf("request body was gzipped, decompressed in %s", time.Since(s))
} else {
@ -213,7 +215,7 @@ func (e *Router) pushMessagesHandlerWeb(w http.ResponseWriter, r *http.Request)
bodySize = len(bodyBytes)
// DEBUG: print body
log.Printf("first bytes: %+v", bodyBytes[:10])
log.Printf("[decompressed] first bytes: %+v", bodyBytes[:10])
// Send processed messages to queue as array of bytes
// TODO: check bytes for nonsense crap

View file

@ -18,8 +18,7 @@ func recordMetrics(requestStart time.Time, url string, code, bodySize int) {
}
func ResponseOK(w http.ResponseWriter, requestStart time.Time, url string, bodySize int) {
httpCodeHelper(w, http.StatusOK)
//w.WriteHeader(http.StatusOK)
w.WriteHeader(http.StatusOK)
recordMetrics(requestStart, url, http.StatusOK, bodySize)
}
@ -28,8 +27,6 @@ func ResponseWithJSON(w http.ResponseWriter, res interface{}, requestStart time.
if err != nil {
log.Println(err)
}
// test
httpCodeHelper(w, http.StatusOK)
w.Header().Set("Content-Type", "application/json")
w.Write(body)
recordMetrics(requestStart, url, http.StatusOK, bodySize)
@ -44,13 +41,7 @@ func ResponseWithError(w http.ResponseWriter, code int, err error, requestStart
if err != nil {
log.Println(err)
}
httpCodeHelper(w, code)
//w.WriteHeader(code)
w.WriteHeader(code)
w.Write(body)
recordMetrics(requestStart, url, code, bodySize)
}
func httpCodeHelper(w http.ResponseWriter, code int) {
w.WriteHeader(code)
log.Printf("HTTP response code: %d", code)
}