message options
This commit is contained in:
parent
7e872d1275
commit
38ada730bb
4
http.go
4
http.go
@ -180,8 +180,8 @@ func (h *httpClient) Options() client.Options {
|
|||||||
return h.opts
|
return h.opts
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *httpClient) NewMessage(topic string, msg interface{}) client.Message {
|
func (h *httpClient) NewMessage(topic string, msg interface{}, opts ...client.MessageOption) client.Message {
|
||||||
return newHTTPMessage(topic, msg, "application/proto")
|
return newHTTPMessage(topic, msg, "application/proto", opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *httpClient) NewRequest(service, method string, req interface{}, reqOpts ...client.RequestOption) client.Request {
|
func (h *httpClient) NewRequest(service, method string, req interface{}, reqOpts ...client.RequestOption) client.Request {
|
||||||
|
11
message.go
11
message.go
@ -10,7 +10,16 @@ type httpMessage struct {
|
|||||||
payload interface{}
|
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{
|
return &httpMessage{
|
||||||
payload: payload,
|
payload: payload,
|
||||||
topic: topic,
|
topic: topic,
|
||||||
|
Loading…
Reference in New Issue
Block a user