Refactor PageResult creation.
diff --git a/pagination/http.go b/pagination/http.go
index cabcccd..1b3fe94 100644
--- a/pagination/http.go
+++ b/pagination/http.go
@@ -36,13 +36,19 @@
parsedBody = rawBody
}
+ return PageResultFromParsed(resp, parsedBody), err
+}
+
+// PageResultFromParsed constructs a PageResult from an HTTP response that has already had its
+// body parsed as JSON (and closed).
+func PageResultFromParsed(resp *http.Response, body interface{}) PageResult {
return PageResult{
Result: gophercloud.Result{
- Body: parsedBody,
+ Body: body,
Header: resp.Header,
},
URL: *resp.Request.URL,
- }, err
+ }
}
// Request performs an HTTP request and extracts the http.Response from the result.