()
| 70 | type Links map[string]interface{} |
| 71 | |
| 72 | func (l *Links) validate() (err error) { |
| 73 | // Each member of a links object is a “link”. A link MUST be represented as |
| 74 | // either: |
| 75 | // - a string containing the link’s URL. |
| 76 | // - an object (“link object”) which can contain the following members: |
| 77 | // - href: a string containing the link’s URL. |
| 78 | // - meta: a meta object containing non-standard meta-information about the |
| 79 | // link. |
| 80 | for k, v := range *l { |
| 81 | _, isString := v.(string) |
| 82 | _, isLink := v.(Link) |
| 83 | |
| 84 | if !(isString || isLink) { |
| 85 | return fmt.Errorf( |
| 86 | "The %s member of the links object was not a string or link object", |
| 87 | k, |
| 88 | ) |
| 89 | } |
| 90 | } |
| 91 | return |
| 92 | } |
| 93 | |
| 94 | // Link is used to represent a member of the `links` object. |
| 95 | type Link struct { |
no test coverage detected