Fix header write order
Headers need to be written before status code
This commit is contained in:
parent
2bc73d2262
commit
b1bdc945b7
1 changed files with 2 additions and 2 deletions
|
@ -32,8 +32,8 @@ func ProblemDetails(
|
||||||
details *string,
|
details *string,
|
||||||
extras map[string]any,
|
extras map[string]any,
|
||||||
) {
|
) {
|
||||||
w.WriteHeader(statusCode)
|
|
||||||
w.Header().Add("Content-Type", "application/problem+json")
|
w.Header().Add("Content-Type", "application/problem+json")
|
||||||
|
w.WriteHeader(statusCode)
|
||||||
data := map[string]any{
|
data := map[string]any{
|
||||||
"type": errorType,
|
"type": errorType,
|
||||||
"status": statusCode,
|
"status": statusCode,
|
||||||
|
@ -58,8 +58,8 @@ func ProblemDetails(
|
||||||
// Write a simple problem details response.
|
// Write a simple problem details response.
|
||||||
// It only provides the status code, as defined in RFC 9457, section 4.2.1
|
// It only provides the status code, as defined in RFC 9457, section 4.2.1
|
||||||
func ProblemDetailsStatusOnly(w http.ResponseWriter, statusCode int) {
|
func ProblemDetailsStatusOnly(w http.ResponseWriter, statusCode int) {
|
||||||
w.WriteHeader(statusCode)
|
|
||||||
w.Header().Add("Content-Type", "application/problem+json")
|
w.Header().Add("Content-Type", "application/problem+json")
|
||||||
|
w.WriteHeader(statusCode)
|
||||||
data := map[string]any{
|
data := map[string]any{
|
||||||
"type": "about:blank",
|
"type": "about:blank",
|
||||||
"title": http.StatusText(statusCode),
|
"title": http.StatusText(statusCode),
|
||||||
|
|
Loading…
Reference in a new issue