Skip to content

Commit 525d408

Browse files
committed
Updated
1 parent 6f215c5 commit 525d408

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/httpresponse/json.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ import (
1717
func JSON(w http.ResponseWriter, code, indent int, v any) error {
1818
// Set the default content type, write the header
1919
w.Header().Set(types.ContentTypeHeader, types.ContentTypeJSON)
20+
21+
// Modify the status code if it is not already set
22+
if code == 0 {
23+
code = http.StatusInternalServerError
24+
}
25+
26+
// Write the status code
2027
w.WriteHeader(code)
2128

2229
// Create an encoder for the response

0 commit comments

Comments
 (0)