[v3] fix panic on publish methods (#167)
Some checks failed
coverage / build (push) Successful in 3m8s
test / test (push) Failing after 18m47s

* move publish methods to a separate file
* reorder client methods
* fix panic for publish
* refactoring
* go mod tidy
* rename go.micro => micro
* add comment to README about Set-Cookie headers
This commit is contained in:
2025-10-29 11:20:04 +05:00
committed by GitHub
parent cee0fde959
commit 3f3c3a4471
6 changed files with 126 additions and 114 deletions

View File

@@ -5,40 +5,24 @@ import (
"go.unistack.org/micro/v3/metadata"
)
type httpEvent struct {
payload interface{}
topic string
contentType string
opts client.MessageOptions
type httpMessage struct {
topic string
payload interface{}
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 (m *httpMessage) Topic() string {
return m.topic
}
func (c *httpEvent) ContentType() string {
return c.contentType
func (m *httpMessage) Payload() interface{} {
return m.payload
}
func (c *httpEvent) Topic() string {
return c.topic
func (m *httpMessage) ContentType() string {
return m.opts.ContentType
}
func (c *httpEvent) Payload() interface{} {
return c.payload
}
func (c *httpEvent) Metadata() metadata.Metadata {
return c.opts.Metadata
func (m *httpMessage) Metadata() metadata.Metadata {
return m.opts.Metadata
}