1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-24 20:14:31 +02:00
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2016-03-16 16:27:31 -07:00
parent 111d65a5b4
commit 9795e59c43
4 changed files with 44 additions and 0 deletions

View File

@ -57,6 +57,7 @@ type (
Del(string)
Set(string, string)
Get(string) string
Keys() []string
}
// URL defines the interface for HTTP request url.

View File

@ -36,6 +36,17 @@ func (h *RequestHeader) Get(key string) string {
return string(h.Peek(key))
}
// Keys implements `engine.Header#Keys` method.
func (h *RequestHeader) Keys() (keys []string) {
keys = make([]string, h.Len())
i := 0
h.VisitAll(func(k, v []byte) {
keys[i] = string(k)
i++
})
return
}
func (h *RequestHeader) reset(hdr *fasthttp.RequestHeader) {
h.RequestHeader = hdr
}
@ -61,6 +72,17 @@ func (h *ResponseHeader) Set(key, val string) {
h.ResponseHeader.Set(key, val)
}
// Keys implements `engine.Header#Keys` method.
func (h *ResponseHeader) Keys() (keys []string) {
keys = make([]string, h.Len())
i := 0
h.VisitAll(func(k, v []byte) {
keys[i] = string(k)
i++
})
return
}
func (h *ResponseHeader) reset(hdr *fasthttp.ResponseHeader) {
h.ResponseHeader = hdr
}

View File

@ -29,6 +29,17 @@ func (h *Header) Get(key string) string {
return h.Header.Get(key)
}
// Keys implements `engine.Header#Keys` method.
func (h *Header) Keys() (keys []string) {
keys = make([]string, len(h.Header))
i := 0
for k := range h.Header {
keys[i] = k
i++
}
return
}
func (h *Header) reset(hdr http.Header) {
h.Header = hdr
}

View File

@ -24,6 +24,16 @@ func (h *Header) Set(key, val string) {
h.header.Set(key, val)
}
func (h *Header) Keys() (keys []string) {
keys = make([]string, len(h.header))
i := 0
for k := range h.header {
keys[i] = k
i++
}
return
}
func (h *Header) reset(hdr http.Header) {
h.header = hdr
}