forked from porthos-rpc/porthos-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheaders.go
39 lines (32 loc) · 773 Bytes
/
headers.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
package porthos
// Headers represents RPC headers (request and response).
type Headers struct {
headers map[string]interface{}
}
// NewHeaders creates a new Headers object initializing the map.
func NewHeaders() *Headers {
return &Headers{
make(map[string]interface{}),
}
}
// NewHeadersFromMap creates a new Headers from a map.
func NewHeadersFromMap(m map[string]interface{}) *Headers {
return &Headers{
m,
}
}
// Set a header.
func (h *Headers) Set(key string, value interface{}) {
h.headers[key] = value
}
// Get a header.
func (h *Headers) Get(key string) interface{} {
return h.headers[key]
}
// Delete a header.
func (h *Headers) Delete(key string) {
delete(h.headers, key)
}
func (h *Headers) asMap() map[string]interface{} {
return h.headers
}