Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
export Size and Status on Response
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates committed May 9, 2017
1 parent 645b56b commit fd53b91
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions request_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ func RequestLoggerFunc(h Handler) Handler {
ws := c.Response().(*Response)
c.LogFields(logrus.Fields{
"duration": time.Now().Sub(now),
"size": ws.size,
"human_size": humanize.Bytes(uint64(ws.size)),
"status": ws.status,
"size": ws.Size,
"human_size": humanize.Bytes(uint64(ws.Size)),
"status": ws.Status,
})
c.Logger().Info()
}()
Expand Down
8 changes: 4 additions & 4 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ import (
// for the capture of the response status and size to be used for things
// like logging requests.
type Response struct {
status int
size int
Status int
Size int
http.ResponseWriter
}

// WriteHeader sets the status code for a response
func (w *Response) WriteHeader(i int) {
w.status = i
w.Status = i
w.ResponseWriter.WriteHeader(i)
}

// Write the body of the response
func (w *Response) Write(b []byte) (int, error) {
w.size = binary.Size(b)
w.Size = binary.Size(b)
return w.ResponseWriter.Write(b)
}

Expand Down

0 comments on commit fd53b91

Please sign in to comment.