Jon Perritt | 4a59d23 | 2014-10-09 20:21:31 -0500 | [diff] [blame] | 1 | package v1 |
| 2 | |
| 3 | import ( |
| 4 | "net/http" |
| 5 | ) |
| 6 | |
| 7 | // CommonResult is a structure that contains the response and error of a call to an |
| 8 | // object storage endpoint. |
| 9 | type CommonResult struct { |
| 10 | Resp *http.Response |
| 11 | Err error |
| 12 | } |
| 13 | |
| 14 | // ExtractHeaders will extract and return the headers from a *http.Response. |
| 15 | func (cr CommonResult) ExtractHeaders() (http.Header, error) { |
| 16 | if cr.Err != nil { |
| 17 | return nil, cr.Err |
| 18 | } |
| 19 | |
| 20 | var headers http.Header |
| 21 | if cr.Err != nil { |
| 22 | return headers, cr.Err |
| 23 | } |
| 24 | return cr.Resp.Header, nil |
| 25 | } |