Base a pagination.PageResult on gophercloud.Result.
diff --git a/openstack/blockstorage/v1/apiversions/requests.go b/openstack/blockstorage/v1/apiversions/requests.go
index 63ed76a..a56f249 100644
--- a/openstack/blockstorage/v1/apiversions/requests.go
+++ b/openstack/blockstorage/v1/apiversions/requests.go
@@ -9,7 +9,7 @@
// List lists all the Cinder API versions available to end-users.
func List(c *gophercloud.ServiceClient) pagination.Pager {
- return pagination.NewPager(c, listURL(c), func(r pagination.LastHTTPResponse) pagination.Page {
+ return pagination.NewPager(c, listURL(c), func(r pagination.PageResult) pagination.Page {
return APIVersionPage{pagination.SinglePageBase(r)}
})
}
diff --git a/openstack/blockstorage/v1/snapshots/requests.go b/openstack/blockstorage/v1/snapshots/requests.go
index 792e7dd..49b637a 100644
--- a/openstack/blockstorage/v1/snapshots/requests.go
+++ b/openstack/blockstorage/v1/snapshots/requests.go
@@ -134,7 +134,7 @@
url += query
}
- createPage := func(r pagination.LastHTTPResponse) pagination.Page {
+ createPage := func(r pagination.PageResult) pagination.Page {
return ListResult{pagination.SinglePageBase(r)}
}
return pagination.NewPager(client, url, createPage)
diff --git a/openstack/blockstorage/v1/volumes/requests.go b/openstack/blockstorage/v1/volumes/requests.go
index ae97419..2b3aaeb 100644
--- a/openstack/blockstorage/v1/volumes/requests.go
+++ b/openstack/blockstorage/v1/volumes/requests.go
@@ -153,7 +153,7 @@
}
url += query
}
- createPage := func(r pagination.LastHTTPResponse) pagination.Page {
+ createPage := func(r pagination.PageResult) pagination.Page {
return ListResult{pagination.SinglePageBase(r)}
}
return pagination.NewPager(client, url, createPage)
diff --git a/openstack/blockstorage/v1/volumetypes/requests.go b/openstack/blockstorage/v1/volumetypes/requests.go
index 7253a87..c1c3dd5 100644
--- a/openstack/blockstorage/v1/volumetypes/requests.go
+++ b/openstack/blockstorage/v1/volumetypes/requests.go
@@ -78,7 +78,7 @@
// List returns all volume types.
func List(client *gophercloud.ServiceClient) pagination.Pager {
- createPage := func(r pagination.LastHTTPResponse) pagination.Page {
+ createPage := func(r pagination.PageResult) pagination.Page {
return ListResult{pagination.SinglePageBase(r)}
}
diff --git a/openstack/common/extensions/requests.go b/openstack/common/extensions/requests.go
index 79ea63d..f1b9c22 100755
--- a/openstack/common/extensions/requests.go
+++ b/openstack/common/extensions/requests.go
@@ -20,7 +20,7 @@
// List returns a Pager which allows you to iterate over the full collection of extensions.
// It does not accept query parameters.
func List(c *gophercloud.ServiceClient) pagination.Pager {
- return pagination.NewPager(c, ListExtensionURL(c), func(r pagination.LastHTTPResponse) pagination.Page {
+ return pagination.NewPager(c, ListExtensionURL(c), func(r pagination.PageResult) pagination.Page {
return ExtensionPage{pagination.SinglePageBase(r)}
})
}
diff --git a/openstack/compute/v2/flavors/requests.go b/openstack/compute/v2/flavors/requests.go
index 6a2017f..b77a79a 100644
--- a/openstack/compute/v2/flavors/requests.go
+++ b/openstack/compute/v2/flavors/requests.go
@@ -53,8 +53,8 @@
}
url += query
}
- createPage := func(r pagination.LastHTTPResponse) pagination.Page {
- return FlavorPage{pagination.LinkedPageBase{LastHTTPResponse: r}}
+ createPage := func(r pagination.PageResult) pagination.Page {
+ return FlavorPage{pagination.LinkedPageBase{PageResult: r}}
}
return pagination.NewPager(client, url, createPage)
diff --git a/openstack/compute/v2/images/requests.go b/openstack/compute/v2/images/requests.go
index 4c9bc7a..4f93ffa 100644
--- a/openstack/compute/v2/images/requests.go
+++ b/openstack/compute/v2/images/requests.go
@@ -51,8 +51,8 @@
url += query
}
- createPage := func(r pagination.LastHTTPResponse) pagination.Page {
- return ImagePage{pagination.LinkedPageBase{LastHTTPResponse: r}}
+ createPage := func(r pagination.PageResult) pagination.Page {
+ return ImagePage{pagination.LinkedPageBase{PageResult: r}}
}
return pagination.NewPager(client, url, createPage)
diff --git a/openstack/compute/v2/servers/requests.go b/openstack/compute/v2/servers/requests.go
index 490cd6b..4e20036 100644
--- a/openstack/compute/v2/servers/requests.go
+++ b/openstack/compute/v2/servers/requests.go
@@ -69,8 +69,8 @@
url += query
}
- createPageFn := func(r pagination.LastHTTPResponse) pagination.Page {
- return ServerPage{pagination.LinkedPageBase{LastHTTPResponse: r}}
+ createPageFn := func(r pagination.PageResult) pagination.Page {
+ return ServerPage{pagination.LinkedPageBase{PageResult: r}}
}
return pagination.NewPager(client, url, createPageFn)
diff --git a/openstack/identity/v2/extensions/delegate.go b/openstack/identity/v2/extensions/delegate.go
index cee275f..fd6e80e 100644
--- a/openstack/identity/v2/extensions/delegate.go
+++ b/openstack/identity/v2/extensions/delegate.go
@@ -44,7 +44,7 @@
// List returns a Pager which allows you to iterate over the full collection of extensions.
// It does not accept query parameters.
func List(c *gophercloud.ServiceClient) pagination.Pager {
- return common.List(c).WithPageCreator(func(r pagination.LastHTTPResponse) pagination.Page {
+ return common.List(c).WithPageCreator(func(r pagination.PageResult) pagination.Page {
return ExtensionPage{
ExtensionPage: common.ExtensionPage{SinglePageBase: pagination.SinglePageBase(r)},
}
diff --git a/openstack/identity/v2/tenants/requests.go b/openstack/identity/v2/tenants/requests.go
index 5ffeaa7..5a359f5 100644
--- a/openstack/identity/v2/tenants/requests.go
+++ b/openstack/identity/v2/tenants/requests.go
@@ -16,8 +16,8 @@
// List enumerates the Tenants to which the current token has access.
func List(client *gophercloud.ServiceClient, opts *ListOpts) pagination.Pager {
- createPage := func(r pagination.LastHTTPResponse) pagination.Page {
- return TenantPage{pagination.LinkedPageBase{LastHTTPResponse: r}}
+ createPage := func(r pagination.PageResult) pagination.Page {
+ return TenantPage{pagination.LinkedPageBase{PageResult: r}}
}
url := listURL(client)
diff --git a/openstack/identity/v3/endpoints/requests.go b/openstack/identity/v3/endpoints/requests.go
index 345ec19..f05cae7 100644
--- a/openstack/identity/v3/endpoints/requests.go
+++ b/openstack/identity/v3/endpoints/requests.go
@@ -94,8 +94,8 @@
q["per_page"] = strconv.Itoa(opts.Page)
}
- createPage := func(r pagination.LastHTTPResponse) pagination.Page {
- return EndpointPage{pagination.LinkedPageBase{LastHTTPResponse: r}}
+ createPage := func(r pagination.PageResult) pagination.Page {
+ return EndpointPage{pagination.LinkedPageBase{PageResult: r}}
}
u := listURL(client) + utils.BuildQuery(q)
diff --git a/openstack/identity/v3/services/requests.go b/openstack/identity/v3/services/requests.go
index 5673eda..a3eefea 100644
--- a/openstack/identity/v3/services/requests.go
+++ b/openstack/identity/v3/services/requests.go
@@ -52,8 +52,8 @@
}
u := listURL(client) + utils.BuildQuery(q)
- createPage := func(r pagination.LastHTTPResponse) pagination.Page {
- return ServicePage{pagination.LinkedPageBase{LastHTTPResponse: r}}
+ createPage := func(r pagination.PageResult) pagination.Page {
+ return ServicePage{pagination.LinkedPageBase{PageResult: r}}
}
return pagination.NewPager(client, u, createPage)
diff --git a/openstack/networking/v2/apiversions/requests.go b/openstack/networking/v2/apiversions/requests.go
index b653f51..9fb6de1 100644
--- a/openstack/networking/v2/apiversions/requests.go
+++ b/openstack/networking/v2/apiversions/requests.go
@@ -7,7 +7,7 @@
// ListVersions lists all the Neutron API versions available to end-users
func ListVersions(c *gophercloud.ServiceClient) pagination.Pager {
- return pagination.NewPager(c, apiVersionsURL(c), func(r pagination.LastHTTPResponse) pagination.Page {
+ return pagination.NewPager(c, apiVersionsURL(c), func(r pagination.PageResult) pagination.Page {
return APIVersionPage{pagination.SinglePageBase(r)}
})
}
@@ -15,7 +15,7 @@
// ListVersionResources lists all of the different API resources for a particular
// API versions. Typical resources for Neutron might be: networks, subnets, etc.
func ListVersionResources(c *gophercloud.ServiceClient, v string) pagination.Pager {
- return pagination.NewPager(c, apiInfoURL(c, v), func(r pagination.LastHTTPResponse) pagination.Page {
+ return pagination.NewPager(c, apiInfoURL(c, v), func(r pagination.PageResult) pagination.Page {
return APIVersionResourcePage{pagination.SinglePageBase(r)}
})
}
diff --git a/openstack/networking/v2/extensions/layer3/floatingips/requests.go b/openstack/networking/v2/extensions/layer3/floatingips/requests.go
index feb23b3..a0a17fd 100644
--- a/openstack/networking/v2/extensions/layer3/floatingips/requests.go
+++ b/openstack/networking/v2/extensions/layer3/floatingips/requests.go
@@ -35,8 +35,8 @@
return pagination.Pager{Err: err}
}
u := rootURL(c) + q.String()
- return pagination.NewPager(c, u, func(r pagination.LastHTTPResponse) pagination.Page {
- return FloatingIPPage{pagination.LinkedPageBase{LastHTTPResponse: r}}
+ return pagination.NewPager(c, u, func(r pagination.PageResult) pagination.Page {
+ return FloatingIPPage{pagination.LinkedPageBase{PageResult: r}}
})
}
diff --git a/openstack/networking/v2/extensions/layer3/routers/requests.go b/openstack/networking/v2/extensions/layer3/routers/requests.go
index dfdd606..52afc4f 100755
--- a/openstack/networking/v2/extensions/layer3/routers/requests.go
+++ b/openstack/networking/v2/extensions/layer3/routers/requests.go
@@ -37,8 +37,8 @@
return pagination.Pager{Err: err}
}
u := rootURL(c) + q.String()
- return pagination.NewPager(c, u, func(r pagination.LastHTTPResponse) pagination.Page {
- return RouterPage{pagination.LinkedPageBase{LastHTTPResponse: r}}
+ return pagination.NewPager(c, u, func(r pagination.PageResult) pagination.Page {
+ return RouterPage{pagination.LinkedPageBase{PageResult: r}}
})
}
diff --git a/openstack/networking/v2/extensions/lbaas/members/requests.go b/openstack/networking/v2/extensions/lbaas/members/requests.go
index bb4da36..c13f0fe 100644
--- a/openstack/networking/v2/extensions/lbaas/members/requests.go
+++ b/openstack/networking/v2/extensions/lbaas/members/requests.go
@@ -38,8 +38,8 @@
return pagination.Pager{Err: err}
}
u := rootURL(c) + q.String()
- return pagination.NewPager(c, u, func(r pagination.LastHTTPResponse) pagination.Page {
- return MemberPage{pagination.LinkedPageBase{LastHTTPResponse: r}}
+ return pagination.NewPager(c, u, func(r pagination.PageResult) pagination.Page {
+ return MemberPage{pagination.LinkedPageBase{PageResult: r}}
})
}
diff --git a/openstack/networking/v2/extensions/lbaas/monitors/requests.go b/openstack/networking/v2/extensions/lbaas/monitors/requests.go
index 5d4c696..9f8ac9a 100644
--- a/openstack/networking/v2/extensions/lbaas/monitors/requests.go
+++ b/openstack/networking/v2/extensions/lbaas/monitors/requests.go
@@ -44,8 +44,8 @@
}
u := rootURL(c) + q.String()
- return pagination.NewPager(c, u, func(r pagination.LastHTTPResponse) pagination.Page {
- return MonitorPage{pagination.LinkedPageBase{LastHTTPResponse: r}}
+ return pagination.NewPager(c, u, func(r pagination.PageResult) pagination.Page {
+ return MonitorPage{pagination.LinkedPageBase{PageResult: r}}
})
}
diff --git a/openstack/networking/v2/extensions/lbaas/pools/requests.go b/openstack/networking/v2/extensions/lbaas/pools/requests.go
index 42be1fd..6e5b87a 100644
--- a/openstack/networking/v2/extensions/lbaas/pools/requests.go
+++ b/openstack/networking/v2/extensions/lbaas/pools/requests.go
@@ -39,8 +39,8 @@
return pagination.Pager{Err: err}
}
u := rootURL(c) + q.String()
- return pagination.NewPager(c, u, func(r pagination.LastHTTPResponse) pagination.Page {
- return PoolPage{pagination.LinkedPageBase{LastHTTPResponse: r}}
+ return pagination.NewPager(c, u, func(r pagination.PageResult) pagination.Page {
+ return PoolPage{pagination.LinkedPageBase{PageResult: r}}
})
}
diff --git a/openstack/networking/v2/extensions/lbaas/vips/requests.go b/openstack/networking/v2/extensions/lbaas/vips/requests.go
index 606bcc5..6c4ee3d 100644
--- a/openstack/networking/v2/extensions/lbaas/vips/requests.go
+++ b/openstack/networking/v2/extensions/lbaas/vips/requests.go
@@ -56,8 +56,8 @@
return pagination.Pager{Err: err}
}
u := rootURL(c) + q.String()
- return pagination.NewPager(c, u, func(r pagination.LastHTTPResponse) pagination.Page {
- return VIPPage{pagination.LinkedPageBase{LastHTTPResponse: r}}
+ return pagination.NewPager(c, u, func(r pagination.PageResult) pagination.Page {
+ return VIPPage{pagination.LinkedPageBase{PageResult: r}}
})
}
diff --git a/openstack/networking/v2/extensions/security/groups/requests.go b/openstack/networking/v2/extensions/security/groups/requests.go
index 67e95ca..6b33e06 100644
--- a/openstack/networking/v2/extensions/security/groups/requests.go
+++ b/openstack/networking/v2/extensions/security/groups/requests.go
@@ -32,8 +32,8 @@
return pagination.Pager{Err: err}
}
u := rootURL(c) + q.String()
- return pagination.NewPager(c, u, func(r pagination.LastHTTPResponse) pagination.Page {
- return SecGroupPage{pagination.LinkedPageBase{LastHTTPResponse: r}}
+ return pagination.NewPager(c, u, func(r pagination.PageResult) pagination.Page {
+ return SecGroupPage{pagination.LinkedPageBase{PageResult: r}}
})
}
diff --git a/openstack/networking/v2/extensions/security/rules/requests.go b/openstack/networking/v2/extensions/security/rules/requests.go
index 34c9466..f243572 100644
--- a/openstack/networking/v2/extensions/security/rules/requests.go
+++ b/openstack/networking/v2/extensions/security/rules/requests.go
@@ -39,8 +39,8 @@
return pagination.Pager{Err: err}
}
u := rootURL(c) + q.String()
- return pagination.NewPager(c, u, func(r pagination.LastHTTPResponse) pagination.Page {
- return SecGroupRulePage{pagination.LinkedPageBase{LastHTTPResponse: r}}
+ return pagination.NewPager(c, u, func(r pagination.PageResult) pagination.Page {
+ return SecGroupRulePage{pagination.LinkedPageBase{PageResult: r}}
})
}
diff --git a/openstack/networking/v2/networks/requests.go b/openstack/networking/v2/networks/requests.go
index 51c294f..a82eeb2 100644
--- a/openstack/networking/v2/networks/requests.go
+++ b/openstack/networking/v2/networks/requests.go
@@ -73,8 +73,8 @@
url += query
}
- return pagination.NewPager(c, url, func(r pagination.LastHTTPResponse) pagination.Page {
- return NetworkPage{pagination.LinkedPageBase{LastHTTPResponse: r}}
+ return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page {
+ return NetworkPage{pagination.LinkedPageBase{PageResult: r}}
})
}
diff --git a/openstack/networking/v2/ports/requests.go b/openstack/networking/v2/ports/requests.go
index 4e477d3..78aebae 100644
--- a/openstack/networking/v2/ports/requests.go
+++ b/openstack/networking/v2/ports/requests.go
@@ -73,8 +73,8 @@
url += query
}
- return pagination.NewPager(c, url, func(r pagination.LastHTTPResponse) pagination.Page {
- return PortPage{pagination.LinkedPageBase{LastHTTPResponse: r}}
+ return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page {
+ return PortPage{pagination.LinkedPageBase{PageResult: r}}
})
}
diff --git a/openstack/networking/v2/subnets/requests.go b/openstack/networking/v2/subnets/requests.go
index e913e61..17c5b82 100644
--- a/openstack/networking/v2/subnets/requests.go
+++ b/openstack/networking/v2/subnets/requests.go
@@ -72,8 +72,8 @@
url += query
}
- return pagination.NewPager(c, url, func(r pagination.LastHTTPResponse) pagination.Page {
- return SubnetPage{pagination.LinkedPageBase{LastHTTPResponse: r}}
+ return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page {
+ return SubnetPage{pagination.LinkedPageBase{PageResult: r}}
})
}
diff --git a/openstack/objectstorage/v1/containers/requests.go b/openstack/objectstorage/v1/containers/requests.go
index 004ef82..50542f4 100644
--- a/openstack/objectstorage/v1/containers/requests.go
+++ b/openstack/objectstorage/v1/containers/requests.go
@@ -52,8 +52,8 @@
}
}
- createPage := func(r pagination.LastHTTPResponse) pagination.Page {
- p := ContainerPage{pagination.MarkerPageBase{LastHTTPResponse: r}}
+ createPage := func(r pagination.PageResult) pagination.Page {
+ p := ContainerPage{pagination.MarkerPageBase{PageResult: r}}
p.MarkerPageBase.Owner = p
return p
}
diff --git a/openstack/objectstorage/v1/containers/results.go b/openstack/objectstorage/v1/containers/results.go
index 3a6d3be..ec3c1e0 100644
--- a/openstack/objectstorage/v1/containers/results.go
+++ b/openstack/objectstorage/v1/containers/results.go
@@ -67,7 +67,7 @@
// ExtractNames is a function that takes a ListResult and returns the containers' names.
func ExtractNames(page pagination.Page) ([]string, error) {
casted := page.(ContainerPage)
- ct := casted.Header.Get("Content-Type")
+ ct := casted.Headers.Get("Content-Type")
switch {
case strings.HasPrefix(ct, "application/json"):
diff --git a/openstack/objectstorage/v1/objects/requests.go b/openstack/objectstorage/v1/objects/requests.go
index be4d107..49dc9f5 100644
--- a/openstack/objectstorage/v1/objects/requests.go
+++ b/openstack/objectstorage/v1/objects/requests.go
@@ -59,8 +59,8 @@
}
}
- createPage := func(r pagination.LastHTTPResponse) pagination.Page {
- p := ObjectPage{pagination.MarkerPageBase{LastHTTPResponse: r}}
+ createPage := func(r pagination.PageResult) pagination.Page {
+ p := ObjectPage{pagination.MarkerPageBase{PageResult: r}}
p.MarkerPageBase.Owner = p
return p
}
diff --git a/openstack/objectstorage/v1/objects/results.go b/openstack/objectstorage/v1/objects/results.go
index 7bd2861..45a1048 100644
--- a/openstack/objectstorage/v1/objects/results.go
+++ b/openstack/objectstorage/v1/objects/results.go
@@ -64,7 +64,7 @@
// ExtractNames is a function that takes a page of objects and returns only their names.
func ExtractNames(page pagination.Page) ([]string, error) {
casted := page.(ObjectPage)
- ct := casted.Header.Get("Content-Type")
+ ct := casted.Headers.Get("Content-Type")
switch {
case strings.HasPrefix(ct, "application/json"):
parsed, err := ExtractInfo(page)
diff --git a/pagination/http.go b/pagination/http.go
index dd2c2d7..d3bd490 100644
--- a/pagination/http.go
+++ b/pagination/http.go
@@ -11,39 +11,38 @@
"github.com/rackspace/gophercloud"
)
-// LastHTTPResponse stores generic information derived from an HTTP response.
-// This exists primarily because the body of an http.Response can only be used once.
-type LastHTTPResponse struct {
+// PageResult stores the HTTP response that returned the current page of results.
+type PageResult struct {
+ gophercloud.Result
url.URL
- http.Header
- Body interface{}
}
-// RememberHTTPResponse parses an HTTP response as JSON and returns a LastHTTPResponse containing the results.
-// The main reason to do this instead of holding the response directly is that a response body can only be read once.
-// Also, this centralizes the JSON decoding.
-func RememberHTTPResponse(resp http.Response) (LastHTTPResponse, error) {
+// 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{}
defer resp.Body.Close()
rawBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
- return LastHTTPResponse{}, err
+ return PageResult{}, err
}
if strings.HasPrefix(resp.Header.Get("Content-Type"), "application/json") {
err = json.Unmarshal(rawBody, &parsedBody)
if err != nil {
- return LastHTTPResponse{}, err
+ return PageResult{}, err
}
} else {
parsedBody = rawBody
}
- return LastHTTPResponse{
- URL: *resp.Request.URL,
- Header: resp.Header,
- Body: parsedBody,
+ return PageResult{
+ Result: gophercloud.Result{
+ Body: parsedBody,
+ Headers: resp.Header,
+ },
+ URL: *resp.Request.URL,
}, err
}
diff --git a/pagination/linked.go b/pagination/linked.go
index 0376edb..447d4b1 100644
--- a/pagination/linked.go
+++ b/pagination/linked.go
@@ -4,7 +4,7 @@
// LinkedPageBase may be embedded to implement a page that provides navigational "Next" and "Previous" links within its result.
type LinkedPageBase struct {
- LastHTTPResponse
+ PageResult
// LinkPath lists the keys that should be traversed within a response to arrive at the "next" pointer.
// If any link along the path is missing, an empty URL will be returned.
diff --git a/pagination/linked_test.go b/pagination/linked_test.go
index 2621f98..4d3248e 100644
--- a/pagination/linked_test.go
+++ b/pagination/linked_test.go
@@ -57,8 +57,8 @@
client := createClient()
- createPage := func(r LastHTTPResponse) Page {
- return LinkedPageResult{LinkedPageBase{LastHTTPResponse: r}}
+ createPage := func(r PageResult) Page {
+ return LinkedPageResult{LinkedPageBase{PageResult: r}}
}
return NewPager(client, testhelper.Server.URL+"/page1", createPage)
diff --git a/pagination/marker.go b/pagination/marker.go
index 41b493a..e7688c2 100644
--- a/pagination/marker.go
+++ b/pagination/marker.go
@@ -11,7 +11,7 @@
// MarkerPageBase is a page in a collection that's paginated by "limit" and "marker" query parameters.
type MarkerPageBase struct {
- LastHTTPResponse
+ PageResult
// Owner is a reference to the embedding struct.
Owner MarkerPage
diff --git a/pagination/marker_test.go b/pagination/marker_test.go
index e30264c..3b1df1d 100644
--- a/pagination/marker_test.go
+++ b/pagination/marker_test.go
@@ -56,8 +56,8 @@
client := createClient()
- createPage := func(r LastHTTPResponse) Page {
- p := MarkerPageResult{MarkerPageBase{LastHTTPResponse: r}}
+ createPage := func(r PageResult) Page {
+ p := MarkerPageResult{MarkerPageBase{PageResult: r}}
p.MarkerPageBase.Owner = p
return p
}
diff --git a/pagination/pager.go b/pagination/pager.go
index 75fe408..5c20e16 100644
--- a/pagination/pager.go
+++ b/pagination/pager.go
@@ -33,7 +33,7 @@
initialURL string
- createPage func(r LastHTTPResponse) Page
+ createPage func(r PageResult) Page
Err error
@@ -43,7 +43,7 @@
// NewPager constructs a manually-configured pager.
// Supply the URL for the first page, a function that requests a specific page given a URL, and a function that counts a page.
-func NewPager(client *gophercloud.ServiceClient, initialURL string, createPage func(r LastHTTPResponse) Page) Pager {
+func NewPager(client *gophercloud.ServiceClient, initialURL string, createPage func(r PageResult) Page) Pager {
return Pager{
client: client,
initialURL: initialURL,
@@ -53,7 +53,7 @@
// WithPageCreator returns a new Pager that substitutes a different page creation function. This is
// useful for overriding List functions in delegation.
-func (p Pager) WithPageCreator(createPage func(r LastHTTPResponse) Page) Pager {
+func (p Pager) WithPageCreator(createPage func(r PageResult) Page) Pager {
return Pager{
client: p.client,
initialURL: p.initialURL,
@@ -67,7 +67,7 @@
return nil, err
}
- remembered, err := RememberHTTPResponse(resp)
+ remembered, err := PageResultFrom(resp)
if err != nil {
return nil, err
}
diff --git a/pagination/single.go b/pagination/single.go
index a7f6fde..4dd3c5c 100644
--- a/pagination/single.go
+++ b/pagination/single.go
@@ -1,7 +1,7 @@
package pagination
// SinglePageBase may be embedded in a Page that contains all of the results from an operation at once.
-type SinglePageBase LastHTTPResponse
+type SinglePageBase PageResult
// NextPageURL always returns "" to indicate that there are no more pages to return.
func (current SinglePageBase) NextPageURL() (string, error) {
diff --git a/pagination/single_test.go b/pagination/single_test.go
index 31003e5..8817d57 100644
--- a/pagination/single_test.go
+++ b/pagination/single_test.go
@@ -45,7 +45,7 @@
fmt.Fprintf(w, `{ "ints": [1, 2, 3] }`)
})
- createPage := func(r LastHTTPResponse) Page {
+ createPage := func(r PageResult) Page {
return SinglePageResult{SinglePageBase(r)}
}