net/http/response.go

25 lines
351 B
Go
Raw Permalink Normal View History

2024-02-03 16:26:09 +00:00
package http
import (
"errors"
)
var (
ErrHeaderNotFound = errors.New("header not found")
)
type Response struct {
StatusCode int
Headers []*Header
Body []byte
}
func (r *Response) GetHeader(name string) (*Header, error) {
for _, h := range r.Headers {
if h.Name == name {
return h, nil
}
}
return nil, ErrHeaderNotFound
}