broker: pass broker content type if message options not pass it
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -159,6 +159,9 @@ func (b *Broker) Init(opts ...broker.Option) error {
|
||||
|
||||
func (b *Broker) NewMessage(ctx context.Context, hdr metadata.Metadata, body interface{}, opts ...broker.PublishOption) (broker.Message, error) {
|
||||
options := broker.NewPublishOptions(opts...)
|
||||
if options.ContentType == "" {
|
||||
options.ContentType = b.opts.ContentType
|
||||
}
|
||||
m := &memoryMessage{ctx: ctx, hdr: hdr, opts: options}
|
||||
c, err := b.newCodec(m.opts.ContentType)
|
||||
if err == nil {
|
||||
|
@@ -128,6 +128,9 @@ func (m *noopMessage) Unmarshal(dst interface{}, opts ...codec.Option) error {
|
||||
|
||||
func (b *NoopBroker) NewMessage(ctx context.Context, hdr metadata.Metadata, body interface{}, opts ...PublishOption) (Message, error) {
|
||||
options := NewPublishOptions(opts...)
|
||||
if options.ContentType == "" {
|
||||
options.ContentType = b.opts.ContentType
|
||||
}
|
||||
m := &noopMessage{ctx: ctx, hdr: hdr, opts: options}
|
||||
c, err := b.newCodec(m.opts.ContentType)
|
||||
if err == nil {
|
||||
|
Reference in New Issue
Block a user