2017-01-01 18:39:05 +00:00
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
2020-01-31 01:26:39 +03:00
|
|
|
"github.com/micro/go-micro/v2/client"
|
2017-01-01 18:39:05 +00:00
|
|
|
)
|
|
|
|
|
2018-04-17 11:26:18 +01:00
|
|
|
type httpMessage struct {
|
2017-01-01 18:39:05 +00:00
|
|
|
topic string
|
|
|
|
contentType string
|
2018-04-17 11:26:18 +01:00
|
|
|
payload interface{}
|
2017-01-01 18:39:05 +00:00
|
|
|
}
|
|
|
|
|
2018-05-10 17:38:14 +01:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2018-04-17 11:26:18 +01:00
|
|
|
return &httpMessage{
|
|
|
|
payload: payload,
|
2017-01-01 18:39:05 +00:00
|
|
|
topic: topic,
|
|
|
|
contentType: contentType,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-17 11:26:18 +01:00
|
|
|
func (h *httpMessage) ContentType() string {
|
2017-01-01 18:39:05 +00:00
|
|
|
return h.contentType
|
|
|
|
}
|
|
|
|
|
2018-04-17 11:26:18 +01:00
|
|
|
func (h *httpMessage) Topic() string {
|
2017-01-01 18:39:05 +00:00
|
|
|
return h.topic
|
|
|
|
}
|
|
|
|
|
2018-04-17 11:26:18 +01:00
|
|
|
func (h *httpMessage) Payload() interface{} {
|
|
|
|
return h.payload
|
2017-01-01 18:39:05 +00:00
|
|
|
}
|