mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
parent
111d65a5b4
commit
9795e59c43
@ -57,6 +57,7 @@ type (
|
||||
Del(string)
|
||||
Set(string, string)
|
||||
Get(string) string
|
||||
Keys() []string
|
||||
}
|
||||
|
||||
// URL defines the interface for HTTP request url.
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user