From d3abde05ef8fdb85d3b61b118d026ae2e85a09ba Mon Sep 17 00:00:00 2001 From: ayushkedia29 Date: Wed, 27 Mar 2024 12:31:24 +0530 Subject: [PATCH] fix: nats publisher func to encode req --- transport/nats/publisher_fn.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/transport/nats/publisher_fn.go b/transport/nats/publisher_fn.go index 171beeb..29e7cb6 100644 --- a/transport/nats/publisher_fn.go +++ b/transport/nats/publisher_fn.go @@ -3,19 +3,21 @@ package nats import ( "context" "encoding/json" + + "github.com/nats-io/nats.go" natn "github.com/nats-io/nats.go" ) // EncodeJSONRequest is an Encoder that serializes the request as a // JSON object to the Data of the Msg. Many JSON-over-NATS services can use it as // a sensible default. -func EncodeJSONRequest(_ context.Context, msg *natn.Msg, request interface{}) error { +func EncodeJSONRequest(_ context.Context, msg *natn.Msg, request interface{}) (*nats.Msg, error) { b, err := json.Marshal(request) if err != nil { - return err + return nil, err } msg.Data = b - return nil + return msg, nil }