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 }