From cc52696dea605bd81f9ba4b434ff22e5e6794e10 Mon Sep 17 00:00:00 2001 From: capossele <angelocapossele@gmail.com> Date: Fri, 19 Jun 2020 09:29:07 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20Fix=20webapi=20linter=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/message.go | 4 ++-- plugins/webapi/message/sendPayload.go | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/client/message.go b/client/message.go index 65b860cc..a920c336 100644 --- a/client/message.go +++ b/client/message.go @@ -30,9 +30,9 @@ func (api *GoShimmerAPI) FindMessageByID(base58EncodedIDs []string) (*webapi_mes // SendPayload send a message with the given payload. func (api *GoShimmerAPI) SendPayload(payload []byte) (string, error) { - res := &webapi_message.MessageResponse{} + res := &webapi_message.MsgResponse{} if err := api.do(http.MethodPost, routeSendPayload, - &webapi_message.MessageRequest{Payload: payload}, res); err != nil { + &webapi_message.MsgRequest{Payload: payload}, res); err != nil { return "", err } diff --git a/plugins/webapi/message/sendPayload.go b/plugins/webapi/message/sendPayload.go index 1d88b622..159ffe16 100644 --- a/plugins/webapi/message/sendPayload.go +++ b/plugins/webapi/message/sendPayload.go @@ -11,34 +11,34 @@ import ( // sendPayload creates a message of the given payload and // broadcasts it to the node's neighbors. It returns the message ID if successful. func sendPayload(c echo.Context) error { - var request MessageRequest + var request MsgRequest if err := c.Bind(&request); err != nil { log.Info(err.Error()) - return c.JSON(http.StatusBadRequest, MessageResponse{Error: err.Error()}) + return c.JSON(http.StatusBadRequest, MsgResponse{Error: err.Error()}) } //TODO: to check max payload size allowed, if exceeding return an error parsedPayload, _, err := payload.FromBytes(request.Payload) if err != nil { - return c.JSON(http.StatusBadRequest, MessageResponse{Error: "not a valid payload"}) + return c.JSON(http.StatusBadRequest, MsgResponse{Error: "not a valid payload"}) } msg, err := issuer.IssuePayload(parsedPayload) if err != nil { - return c.JSON(http.StatusBadRequest, MessageResponse{Error: err.Error()}) + return c.JSON(http.StatusBadRequest, MsgResponse{Error: err.Error()}) } - return c.JSON(http.StatusOK, MessageResponse{ID: msg.Id().String()}) + return c.JSON(http.StatusOK, MsgResponse{ID: msg.Id().String()}) } -// MessageResponse contains the ID of the message sent. -type MessageResponse struct { +// MsgResponse contains the ID of the message sent. +type MsgResponse struct { ID string `json:"id,omitempty"` Error string `json:"error,omitempty"` } -// MessageRequest contains the message to send. -type MessageRequest struct { +// MsgRequest contains the message to send. +type MsgRequest struct { Payload []byte `json:"payload"` } -- GitLab