add compile-time interface compliance check
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
44
message.go
Normal file
44
message.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/metadata"
|
||||
)
|
||||
|
||||
type httpEvent struct {
|
||||
payload interface{}
|
||||
topic string
|
||||
contentType string
|
||||
opts client.MessageOptions
|
||||
}
|
||||
|
||||
func newHTTPEvent(topic string, payload interface{}, contentType string, opts ...client.MessageOption) client.Message {
|
||||
options := client.NewMessageOptions(opts...)
|
||||
|
||||
if len(options.ContentType) > 0 {
|
||||
contentType = options.ContentType
|
||||
}
|
||||
|
||||
return &httpEvent{
|
||||
payload: payload,
|
||||
topic: topic,
|
||||
contentType: contentType,
|
||||
opts: options,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *httpEvent) ContentType() string {
|
||||
return c.contentType
|
||||
}
|
||||
|
||||
func (c *httpEvent) Topic() string {
|
||||
return c.topic
|
||||
}
|
||||
|
||||
func (c *httpEvent) Payload() interface{} {
|
||||
return c.payload
|
||||
}
|
||||
|
||||
func (c *httpEvent) Metadata() metadata.Metadata {
|
||||
return c.opts.Metadata
|
||||
}
|
||||
Reference in New Issue
Block a user