diff --git a/client/message.go b/client/message.go index 65b860cc50ff24b3a6455850ea7851eae7e2b5d8..a920c336d9acba56b8bf967eff2c2af993f85923 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 1d88b6220b7ec188356e47943bf795d0559efad1..159ffe16f0cc7cd0dcc015e39b09cd005fe5955b 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"` }