diff --git a/publish.go b/publish.go index 1733b6c..dc2c77b 100644 --- a/publish.go +++ b/publish.go @@ -40,6 +40,7 @@ type PublishOptions struct { ContentType string // Transient or Persistent DeliveryMode uint8 + Headers Table } // WithPublishOptionsExchange returns a function that sets the exchange to publish to @@ -76,6 +77,13 @@ func WithPublishOptionsPersistentDelivery(options *PublishOptions) { options.DeliveryMode = Persistent } +// WithPublishOptionsHeaders returns a function that sets message header values, i.e. "msg-id" +func WithPublishOptionsHeaders(headers Table) func(*PublishOptions) { + return func(options *PublishOptions) { + options.Headers = headers + } +} + // Publisher allows you to publish messages safely across an open connection type Publisher struct { chManager *channelManager @@ -182,6 +190,7 @@ func (publisher *Publisher) Publish( options.Mandatory, options.Immediate, amqp.Publishing{ + Headers: tableToAMQPTable(options.Headers), ContentType: options.ContentType, Body: data, DeliveryMode: options.DeliveryMode,