2017-01-01 21:39:05 +03:00
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
2023-04-28 22:29:18 +03:00
|
|
|
"go.unistack.org/micro/v4/client"
|
|
|
|
"go.unistack.org/micro/v4/metadata"
|
2017-01-01 21:39:05 +03:00
|
|
|
)
|
|
|
|
|
2018-04-17 13:26:18 +03:00
|
|
|
type httpMessage struct {
|
2021-04-25 16:26:36 +03:00
|
|
|
payload interface{}
|
2017-01-01 21:39:05 +03:00
|
|
|
topic string
|
|
|
|
contentType string
|
2021-12-16 15:37:49 +03:00
|
|
|
opts client.MessageOptions
|
2017-01-01 21:39:05 +03:00
|
|
|
}
|
|
|
|
|
2018-05-10 19:38:14 +03:00
|
|
|
func newHTTPMessage(topic string, payload interface{}, contentType string, opts ...client.MessageOption) client.Message {
|
2021-01-10 14:48:10 +03:00
|
|
|
options := client.NewMessageOptions(opts...)
|
2021-12-16 15:37:49 +03:00
|
|
|
|
|
|
|
if len(options.ContentType) > 0 {
|
|
|
|
contentType = options.ContentType
|
2018-05-10 19:38:14 +03:00
|
|
|
}
|
|
|
|
|
2018-04-17 13:26:18 +03:00
|
|
|
return &httpMessage{
|
|
|
|
payload: payload,
|
2017-01-01 21:39:05 +03:00
|
|
|
topic: topic,
|
2021-12-16 15:37:49 +03:00
|
|
|
contentType: contentType,
|
|
|
|
opts: options,
|
2017-01-01 21:39:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-17 13:26:18 +03:00
|
|
|
func (h *httpMessage) ContentType() string {
|
2017-01-01 21:39:05 +03:00
|
|
|
return h.contentType
|
|
|
|
}
|
|
|
|
|
2018-04-17 13:26:18 +03:00
|
|
|
func (h *httpMessage) Topic() string {
|
2017-01-01 21:39:05 +03:00
|
|
|
return h.topic
|
|
|
|
}
|
|
|
|
|
2018-04-17 13:26:18 +03:00
|
|
|
func (h *httpMessage) Payload() interface{} {
|
|
|
|
return h.payload
|
2017-01-01 21:39:05 +03:00
|
|
|
}
|
2021-12-16 15:37:49 +03:00
|
|
|
|
|
|
|
func (h *httpMessage) Metadata() metadata.Metadata {
|
|
|
|
return h.opts.Metadata
|
|
|
|
}
|