| "github.com/rackspace/gophercloud" |
| // PageResult stores the HTTP response that returned the current page of results. |
| // PageResultFrom parses an HTTP response as JSON and returns a PageResult containing the |
| // results, interpreting it as JSON if the content type indicates. |
| func PageResultFrom(resp *http.Response) (PageResult, error) { |
| var parsedBody interface{} |
| rawBody, err := ioutil.ReadAll(resp.Body) |
| if strings.HasPrefix(resp.Header.Get("Content-Type"), "application/json") { |
| err = json.Unmarshal(rawBody, &parsedBody) |
| Result: gophercloud.Result{ |
| // Request performs an HTTP request and extracts the http.Response from the result. |
| func Request(client *gophercloud.ServiceClient, headers map[string]string, url string) (*http.Response, error) { |
| return client.Request("GET", url, gophercloud.RequestOpts{ |
| OkCodes: []int{200, 204}, |