Skip to content

Commit

Permalink
fix: return updating http metrics (#444)
Browse files Browse the repository at this point in the history
* fix: update latency and count metrics

* fix: error and audit event metrics
  • Loading branch information
DimkaGorhover authored Feb 20, 2024
1 parent 14408fb commit 6091de4
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 121 deletions.
14 changes: 14 additions & 0 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ type Response struct {
http.ResponseWriter
}

var (
_ http.ResponseWriter = (*Response)(nil)
_ http.Flusher = (*Response)(nil)
)

// Reply is a shorthand for api.Reply. It sends just an HTTP
// status code to the client. The response body is empty.
func (r *Response) Reply(code int) { Reply(r, code) }
Expand Down Expand Up @@ -245,6 +250,15 @@ func ReplyWith(r *Response, code int, data any) error {
return json.NewEncoder(r).Encode(data)
}

// Flush sends any buffered data to the client.
//
// This method will be called by http.ResponseController.
func (r *Response) Flush() {
if flusher, ok := r.ResponseWriter.(http.Flusher); ok {
flusher.Flush()
}
}

// ReadBody reads the request body into v using the
// request content encoding.
//
Expand Down
Loading

0 comments on commit 6091de4

Please sign in to comment.