Skip to content

Commit

Permalink
Update client (#32)
Browse files Browse the repository at this point in the history
* sample client

* fix server

* simpler
  • Loading branch information
decentralgabe authored Oct 31, 2023
1 parent f0cd1d9 commit 4abb58c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion impl/pkg/server/pkarr.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,5 @@ func (r *PKARRRouter) PutRecord(c *gin.Context) {
return
}

Respond(c, nil, http.StatusOK)
ResponseStatus(c, http.StatusOK)
}
7 changes: 6 additions & 1 deletion impl/pkg/server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 4abb58c

Please sign in to comment.