CHANGE: Corrected The Use Of Title In The ProblemDetail Response
Build, Push and Deploy CMS / build-push-deploy (push) Successful in 2m0s

This commit is contained in:
FahdShalhoub
2026-08-16 23:28:46 +03:00
parent 0dae4abb74
commit cdc5315401
2 changed files with 26 additions and 15 deletions
+6 -5
View File
@@ -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,
})