mirror of
https://github.com/coder/coder.git
synced 2025-07-18 14:17:22 +00:00
feat: trace httpapi.{Read,Write} (#4134)
This commit is contained in:
@ -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,
|
||||
})
|
||||
|
Reference in New Issue
Block a user