don't leave HomeDocument body as string
diff --git a/openstack/cdn/v1/base/requests_test.go b/openstack/cdn/v1/base/requests_test.go
index 4077022..a8d95f9 100644
--- a/openstack/cdn/v1/base/requests_test.go
+++ b/openstack/cdn/v1/base/requests_test.go
@@ -16,21 +16,19 @@
th.CheckNoErr(t, err)
expected := HomeDocument{
- "rel/cdn": `{
+ "rel/cdn": map[string]interface{}{
"href-template": "services{?marker,limit}",
- "href-vars": {
+ "href-vars": map[string]interface{}{
"marker": "param/marker",
- "limit": "param/limit"
+ "limit": "param/limit",
},
- "hints": {
- "allow": [
- "GET"
- ],
- "formats": {
- "application/json": {}
- }
- }
- }`,
+ "hints": map[string]interface{}{
+ "allow": []string{"GET"},
+ "formats": map[string]interface{}{
+ "application/json": map[string]interface{}{},
+ },
+ },
+ },
}
th.CheckDeepEquals(t, expected, *actual)
}
diff --git a/openstack/cdn/v1/base/results.go b/openstack/cdn/v1/base/results.go
index da6ad2f..bef1da8 100644
--- a/openstack/cdn/v1/base/results.go
+++ b/openstack/cdn/v1/base/results.go
@@ -1,7 +1,8 @@
package base
import (
- "github.com/mitchellh/mapstructure"
+ "errors"
+
"github.com/rackspace/gophercloud"
)
@@ -19,13 +20,13 @@
return nil, r.Err
}
- var res struct {
- HomeDocument *HomeDocument `mapstructure:"resources"`
+ submap, ok := r.Body.(map[string]interface{})["resources"]
+ if !ok {
+ return nil, errors.New("Unexpected HomeDocument structure")
}
+ casted := HomeDocument(submap.(map[string]interface{}))
- err := mapstructure.Decode(r.Body, &res)
-
- return res.HomeDocument, err
+ return &casted, nil
}
// PingResult represents the result of a Ping operation.