add commonResult types for ExtractHeaders method
diff --git a/openstack/objectstorage/v1/containers/results.go b/openstack/objectstorage/v1/containers/results.go
index 5df99ed..80425bd 100644
--- a/openstack/objectstorage/v1/containers/results.go
+++ b/openstack/objectstorage/v1/containers/results.go
@@ -2,56 +2,19 @@
import (
"fmt"
- "github.com/mitchellh/mapstructure"
- "github.com/rackspace/gophercloud"
- "github.com/rackspace/gophercloud/pagination"
"net/http"
"strings"
+
+ "github.com/mitchellh/mapstructure"
+ "github.com/rackspace/gophercloud/pagination"
)
type Container struct {
Bytes int `json:"bytes" mapstructure:"bytes"`
Count int `json:"count" mapstructure:"count"`
- Name string `json:"name" mapstructure:"name"`
+ Name string `json:"name" mapstructure:"name"`
}
-type commonResult struct {
- gophercloud.CommonResult
-}
-
-func (r GetResult) Extract() (*Container, error) {
- if r.Err != nil {
- return nil, r.Err
- }
-
- var res struct {
- Container *Container
- }
-
- err := mapstructure.Decode(r.Resp, &res)
- if err != nil {
- return nil, fmt.Errorf("Error decoding Object Storage Container: %v", err)
- }
-
- return res.Container, nil
-}
-
-type CreateResult struct {
- commonResult
-}
-
-// GetResult represents the result of a get operation.
-type GetResult struct {
- Resp *http.Response
- Err error
-}
-
-// UpdateResult represents the result of an update operation.
-type UpdateResult commonResult
-
-// DeleteResult represents the result of a delete operation.
-type DeleteResult commonResult
-
// ListResult is a *http.Response that is returned from a call to the List function.
type ContainerPage struct {
pagination.MarkerPageBase
@@ -125,6 +88,12 @@
}
}
+// GetResult represents the result of a get operation.
+type GetResult struct {
+ Resp *http.Response
+ Err error
+}
+
// ExtractMetadata is a function that takes a GetResult (of type *http.Response)
// and returns the custom metadata associated with the container.
func (gr GetResult) ExtractMetadata() (map[string]string, error) {
@@ -140,3 +109,29 @@
}
return metadata, nil
}
+
+type commonResult struct {
+ Resp *http.Response
+ Err error
+}
+
+func (cr commonResult) ExtractHeaders() (http.Header, error) {
+ var headers http.Header
+ if cr.Err != nil {
+ return headers, cr.Err
+ }
+
+ return cr.Resp.Header, nil
+}
+
+type CreateResult struct {
+ commonResult
+}
+
+type UpdateResult struct {
+ commonResult
+}
+
+type DeleteResult struct {
+ commonResult
+}