Skip to content

Commit

Permalink
refactor: removed headers struct
Browse files Browse the repository at this point in the history
  • Loading branch information
stanipetrosyan committed Nov 10, 2024
1 parent f3bea60 commit 3956448
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions message_headers.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package goeventbus

type Headers struct {
headers map[string]string
}

type MessageHeaders struct {
headers Headers
headers map[string]string
}

type MessageHeadersBuilder interface {
Expand All @@ -18,29 +14,23 @@ type defaultMessageHeadersBuilder struct {
}

func NewMessageHeadersBuilder() MessageHeadersBuilder {
return &defaultMessageHeadersBuilder{messageHeaders: MessageHeaders{Headers{headers: map[string]string{}}}}
return &defaultMessageHeadersBuilder{messageHeaders: MessageHeaders{headers: map[string]string{}}}
}

func (hb *defaultMessageHeadersBuilder) SetHeader(key string, value string) MessageHeadersBuilder {
hb.messageHeaders.headers.headers[key] = value
hb.messageHeaders.headers[key] = value
return hb
}

func (hb *defaultMessageHeadersBuilder) Build() MessageHeaders {
return hb.messageHeaders
}

func NewMessageHeaders() MessageHeaders {
return MessageHeaders{
headers: Headers{},
}
}

func (h MessageHeaders) Get(key string) string {
return h.headers.headers[key]
return h.headers[key]
}

func (h MessageHeaders) Contains(key string) bool {
_, exist := h.headers.headers[key]
_, exist := h.headers[key]
return exist
}

0 comments on commit 3956448

Please sign in to comment.