From 5de4f673442604bd8217e15273be80969b990bf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Fri, 9 Jun 2023 21:37:30 +0200 Subject: [PATCH] use nil-safe json renderer in ginresp --- scnserver/api/ginresp/resp.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scnserver/api/ginresp/resp.go b/scnserver/api/ginresp/resp.go index 1d4dd4b..2243611 100644 --- a/scnserver/api/ginresp/resp.go +++ b/scnserver/api/ginresp/resp.go @@ -8,6 +8,7 @@ import ( "fmt" "github.com/gin-gonic/gin" "github.com/rs/zerolog/log" + json "gogs.mikescher.com/BlackForestBytes/goext/gojson" "gogs.mikescher.com/BlackForestBytes/goext/langext" "runtime/debug" "strings" @@ -26,7 +27,7 @@ type jsonHTTPResponse struct { } func (j jsonHTTPResponse) Write(g *gin.Context) { - g.JSON(j.statusCode, j.data) + g.Render(j.statusCode, json.GoJsonRender{Data: j.data, NilSafeSlices: true, NilSafeMaps: true}) } func (j jsonHTTPResponse) Statuscode() int {