Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return updating http metrics #444

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading