From a1094ff8efa83ff5e27dfb6e223112b701ed2393 Mon Sep 17 00:00:00 2001 From: Ralph Pichler Date: Mon, 1 Feb 2021 11:14:29 +0100 Subject: [PATCH] api: use hex encoding in postage api (#1179) --- pkg/api/postage.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/api/postage.go b/pkg/api/postage.go index fdb9fce72fb..be6dc1e54c5 100644 --- a/pkg/api/postage.go +++ b/pkg/api/postage.go @@ -5,6 +5,8 @@ package api import ( + "encoding/hex" + "encoding/json" "errors" "math/big" "net/http" @@ -15,8 +17,14 @@ import ( "github.com/gorilla/mux" ) +type batchID []byte + +func (b batchID) MarshalJSON() ([]byte, error) { + return json.Marshal(hex.EncodeToString(b)) +} + type postageCreateResponse struct { - BatchID []byte `json:"batchID"` + BatchID batchID `json:"batchID"` } func (s *server) postageCreateHandler(w http.ResponseWriter, r *http.Request) {