25 lines
351 B
Go
25 lines
351 B
Go
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
|
|
}
|