Skip to content
This repository was archived by the owner on Jun 12, 2024. It is now read-only.

Commit 16b09e2

Browse files
authored
dont send null bodies. (#19)
1 parent 6a506da commit 16b09e2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pkg/http/handlers/base.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ func (h *baseHandler) Write(ctx context.Context, w http.ResponseWriter, status i
120120

121121
w.Header().Set("Content-Type", "application/json")
122122
w.WriteHeader(status)
123-
enc := json.NewEncoder(w)
124-
err = enc.Encode(obj)
123+
if obj != nil {
124+
enc := json.NewEncoder(w)
125+
err = enc.Encode(obj)
126+
}
125127
}
126128

127129
func (h *baseHandler) Parse(r *http.Request, out interface{}) error {

0 commit comments

Comments
 (0)