message options

This commit is contained in:
Asim Aslam 2018-05-10 17:38:14 +01:00 committed by Vasiliy Tolstov
parent 7e872d1275
commit 38ada730bb
2 changed files with 12 additions and 3 deletions

View File

@ -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 {

View File

@ -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,