feat: trace httpapi.{Read,Write} (#4134)

This commit is contained in:
Colin Adler
2022-09-21 17:07:00 -05:00
committed by GitHub
parent 1bf2dc0cc3
commit 5de6f86959
45 changed files with 919 additions and 774 deletions

View File

@ -12,6 +12,7 @@ import (
// parsePagination extracts pagination query params from the http request.
// If an error is encountered, the error is written to w and ok is set to false.
func parsePagination(w http.ResponseWriter, r *http.Request) (p codersdk.Pagination, ok bool) {
ctx := r.Context()
queryParams := r.URL.Query()
parser := httpapi.NewQueryParamParser()
params := codersdk.Pagination{
@ -21,7 +22,7 @@ func parsePagination(w http.ResponseWriter, r *http.Request) (p codersdk.Paginat
Offset: parser.Int(queryParams, 0, "offset"),
}
if len(parser.Errors) > 0 {
httpapi.Write(w, http.StatusBadRequest, codersdk.Response{
httpapi.Write(ctx, w, http.StatusBadRequest, codersdk.Response{
Message: "Query parameters have invalid values.",
Validations: parser.Errors,
})