Skip to content

Commit d9b8f7a

Browse files
committed
fix: use default title based on status code
1 parent 6301ca8 commit d9b8f7a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

problem_details.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package httpsuite
22

3-
import "sync"
3+
import (
4+
"net/http"
5+
"sync"
6+
)
47

58
const BlankUrl = "about:blank"
69

@@ -30,6 +33,12 @@ func NewProblemDetails(status int, problemType, title, detail string) *ProblemDe
3033
if problemType == "" {
3134
problemType = BlankUrl
3235
}
36+
if title == "" {
37+
title = http.StatusText(status)
38+
if title == "" {
39+
title = "Unknown error"
40+
}
41+
}
3342
return &ProblemDetails{
3443
Type: problemType,
3544
Title: title,

0 commit comments

Comments
 (0)