From 4abb58cafa2ef4db6a2488edf25781a368714a84 Mon Sep 17 00:00:00 2001 From: Gabe <7622243+decentralgabe@users.noreply.github.com> Date: Tue, 31 Oct 2023 23:04:28 +0100 Subject: [PATCH] Update client (#32) * sample client * fix server * simpler --- impl/pkg/server/pkarr.go | 2 +- impl/pkg/server/util.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/impl/pkg/server/pkarr.go b/impl/pkg/server/pkarr.go index 98f1d293..ac8d200e 100644 --- a/impl/pkg/server/pkarr.go +++ b/impl/pkg/server/pkarr.go @@ -120,5 +120,5 @@ func (r *PKARRRouter) PutRecord(c *gin.Context) { return } - Respond(c, nil, http.StatusOK) + ResponseStatus(c, http.StatusOK) } diff --git a/impl/pkg/server/util.go b/impl/pkg/server/util.go index 8a4d1649..fef9a26c 100644 --- a/impl/pkg/server/util.go +++ b/impl/pkg/server/util.go @@ -65,10 +65,15 @@ func Respond(c *gin.Context, data any, statusCode int) { c.PureJSON(statusCode, data) } +// ResponseStatus sends a response with a status code and no body. +func ResponseStatus(c *gin.Context, statusCode int) { + c.Status(statusCode) +} + // RespondBytes sends a byte array to the client. func RespondBytes(c *gin.Context, data []byte, statusCode int) { // if there's no payload to marshal, set the status code of the response and return - if statusCode == http.StatusNoContent { + if statusCode == http.StatusNoContent || data == nil { c.Status(statusCode) return }