-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathheader.go
55 lines (41 loc) · 946 Bytes
/
header.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package room
import "github.com/WEG-Technology/room/store"
type IHeader interface {
Properties() store.IMap
Add(key string, value string) IHeader
Get(key string) string
Merge(header IHeader) IHeader
String() string
}
type Header struct {
properties store.IMap
}
func (h *Header) Add(key string, value string) IHeader {
h.properties.Add(key, value)
return h
}
func (h *Header) Get(key string) string {
s, ok := h.properties.GetItem(key)
if !ok {
return ""
}
return s.(string)
}
func (h *Header) Merge(header IHeader) IHeader {
if header != nil {
h.properties = h.properties.MergeIMap(header.Properties())
}
return h
}
func (h *Header) Properties() store.IMap {
return h.properties
}
func (h *Header) String() (str string) {
return h.Properties().StringAll()
}
func NewHeader(properties ...store.IMap) IHeader {
if len(properties) == 0 {
return &Header{store.NewMapStore()}
}
return &Header{properties[0]}
}