We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6f215c5 commit 525d408Copy full SHA for 525d408
pkg/httpresponse/json.go
@@ -17,6 +17,13 @@ import (
17
func JSON(w http.ResponseWriter, code, indent int, v any) error {
18
// Set the default content type, write the header
19
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
27
w.WriteHeader(code)
28
29
// Create an encoder for the response
0 commit comments