CHANGE: Corrected The Use Of Title In The ProblemDetail Response
Build, Push and Deploy CMS / build-push-deploy (push) Successful in 2m0s
Build, Push and Deploy CMS / build-push-deploy (push) Successful in 2m0s
This commit is contained in:
@@ -12,9 +12,10 @@ func Health(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// problemDetails is an error body in the RFC 9457 "Problem Details for HTTP
|
||||
// APIs" format. Type stays "about:blank" — the value RFC 9457 defines for
|
||||
// problems with no dedicated documentation URI — which is why Title carries
|
||||
// the plain HTTP status phrase and Detail carries the occurrence-specific
|
||||
// explanation.
|
||||
// problems with no dedicated documentation URI. Title is a short summary that
|
||||
// stays identical for every occurrence of the same problem, so clients can
|
||||
// branch on it; Detail explains this particular occurrence and is the only
|
||||
// member that varies with request data.
|
||||
type problemDetails struct {
|
||||
Type string `json:"type"`
|
||||
Title string `json:"title"`
|
||||
@@ -26,10 +27,10 @@ func writeJSON(w http.ResponseWriter, status int, body any) {
|
||||
writeJSONContent(w, "application/json", status, body)
|
||||
}
|
||||
|
||||
func writeProblem(w http.ResponseWriter, status int, detail string) {
|
||||
func writeProblem(w http.ResponseWriter, status int, title, detail string) {
|
||||
writeJSONContent(w, "application/problem+json", status, problemDetails{
|
||||
Type: "about:blank",
|
||||
Title: http.StatusText(status),
|
||||
Title: title,
|
||||
Status: status,
|
||||
Detail: detail,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user