From 38ada730bbf8e33a219dc2ad109b3c67f6a3d168 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Thu, 10 May 2018 17:38:14 +0100 Subject: [PATCH] message options --- http.go | 4 ++-- message.go | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/http.go b/http.go index eee3a3f..1194d5c 100644 --- a/http.go +++ b/http.go @@ -180,8 +180,8 @@ func (h *httpClient) Options() client.Options { return h.opts } -func (h *httpClient) NewMessage(topic string, msg interface{}) client.Message { - return newHTTPMessage(topic, msg, "application/proto") +func (h *httpClient) NewMessage(topic string, msg interface{}, opts ...client.MessageOption) client.Message { + return newHTTPMessage(topic, msg, "application/proto", opts...) } func (h *httpClient) NewRequest(service, method string, req interface{}, reqOpts ...client.RequestOption) client.Request { diff --git a/message.go b/message.go index 8d74fcf..b12728a 100644 --- a/message.go +++ b/message.go @@ -10,7 +10,16 @@ type httpMessage struct { payload interface{} } -func newHTTPMessage(topic string, payload interface{}, contentType string) client.Message { +func newHTTPMessage(topic string, payload interface{}, contentType string, opts ...client.MessageOption) client.Message { + var options client.MessageOptions + for _, o := range opts { + o(&options) + } + + if len(options.ContentType) > 0 { + contentType = options.ContentType + } + return &httpMessage{ payload: payload, topic: topic,