NewRequest creates a new request helper object for accessing runtime.Objects on a server.
(client HTTPClient, verb string, baseURL *url.URL, versionedAPIPath string, content ContentConfig, serializers Serializers, backoff BackoffManager, throttle flowcontrol.RateLimiter, timeout time.Duration)
| 113 | |
| 114 | // NewRequest creates a new request helper object for accessing runtime.Objects on a server. |
| 115 | func NewRequest(client HTTPClient, verb string, baseURL *url.URL, versionedAPIPath string, content ContentConfig, serializers Serializers, backoff BackoffManager, throttle flowcontrol.RateLimiter, timeout time.Duration) *Request { |
| 116 | if backoff == nil { |
| 117 | klog.V(2).Infof("Not implementing request backoff strategy.") |
| 118 | backoff = &NoBackoff{} |
| 119 | } |
| 120 | |
| 121 | pathPrefix := "/" |
| 122 | if baseURL != nil { |
| 123 | pathPrefix = path.Join(pathPrefix, baseURL.Path) |
| 124 | } |
| 125 | r := &Request{ |
| 126 | client: client, |
| 127 | verb: verb, |
| 128 | baseURL: baseURL, |
| 129 | pathPrefix: path.Join(pathPrefix, versionedAPIPath), |
| 130 | content: content, |
| 131 | serializers: serializers, |
| 132 | backoffMgr: backoff, |
| 133 | throttle: throttle, |
| 134 | timeout: timeout, |
| 135 | } |
| 136 | switch { |
| 137 | case len(content.AcceptContentTypes) > 0: |
| 138 | r.SetHeader("Accept", content.AcceptContentTypes) |
| 139 | case len(content.ContentType) > 0: |
| 140 | r.SetHeader("Accept", content.ContentType+", */*") |
| 141 | } |
| 142 | return r |
| 143 | } |
| 144 | |
| 145 | // Prefix adds segments to the relative beginning to the request path. These |
| 146 | // items will be placed before the optional Namespace, Resource, or Name sections. |