SubResource sets a sub-resource path which can be multiple segments after the resource name but before the suffix.
(subresources ...string)
| 201 | // SubResource sets a sub-resource path which can be multiple segments after the resource |
| 202 | // name but before the suffix. |
| 203 | func (r *Request) SubResource(subresources ...string) *Request { |
| 204 | if r.err != nil { |
| 205 | return r |
| 206 | } |
| 207 | subresource := path.Join(subresources...) |
| 208 | if len(r.subresource) != 0 { |
| 209 | r.err = fmt.Errorf("subresource already set to %q, cannot change to %q", r.resource, subresource) |
| 210 | return r |
| 211 | } |
| 212 | for _, s := range subresources { |
| 213 | if msgs := IsValidPathSegmentName(s); len(msgs) != 0 { |
| 214 | r.err = fmt.Errorf("invalid subresource %q: %v", s, msgs) |
| 215 | return r |
| 216 | } |
| 217 | } |
| 218 | r.subresource = subresource |
| 219 | return r |
| 220 | } |
| 221 | |
| 222 | // Name sets the name of a resource to access (<resource>/[ns/<namespace>/]<name>) |
| 223 | func (r *Request) Name(resourceName string) *Request { |