writeErrorResponse writes a JSON error response using huma's ErrorModel format for consistency with the rest of the API.
(w http.ResponseWriter, status int, detail string)
| 44 | // writeErrorResponse writes a JSON error response using huma's ErrorModel format |
| 45 | // for consistency with the rest of the API. |
| 46 | func writeErrorResponse(w http.ResponseWriter, status int, detail string) { |
| 47 | w.Header().Set("Content-Type", "application/json") |
| 48 | w.WriteHeader(status) |
| 49 | |
| 50 | errModel := &huma.ErrorModel{ |
| 51 | Title: http.StatusText(status), |
| 52 | Status: status, |
| 53 | Detail: detail, |
| 54 | } |
| 55 | _ = json.NewEncoder(w).Encode(errModel) |
| 56 | } |
| 57 | |
| 58 | // containsNulByte checks if a string contains a NUL byte, either as a literal \x00 |
| 59 | // or URL-encoded as %00. |
no test coverage detected
searching dependent graphs…