@@ -157,7 +157,11 @@ func (s *restClient) Authenticate() error {
157
157
158
158
func (s * restClient ) Delete (ctx context.Context , path string , body interface {}, params query.Params , headers map [string ]string ) (* http.Response , error ) {
159
159
endpoint := s .api .ResolveReference (& url.URL {Path : path })
160
- if req , err := NewRequest (ctx , http .MethodDelete , endpoint , body , params .AsMap (), headers ); err != nil {
160
+ paramsMap := make (map [string ]string )
161
+ if params != nil {
162
+ paramsMap = params .AsMap ()
163
+ }
164
+ if req , err := NewRequest (ctx , http .MethodDelete , endpoint , body , paramsMap , headers ); err != nil {
161
165
return nil , err
162
166
} else {
163
167
return s .Send (req )
@@ -166,15 +170,19 @@ func (s *restClient) Delete(ctx context.Context, path string, body interface{},
166
170
167
171
func (s * restClient ) Get (ctx context.Context , path string , params query.Params , headers map [string ]string ) (* http.Response , error ) {
168
172
endpoint := s .api .ResolveReference (& url.URL {Path : path })
173
+ paramsMap := make (map [string ]string )
169
174
170
- if params .NeedsEventualConsistencyHeaderFlag () {
171
- if headers == nil {
172
- headers = make (map [string ]string )
175
+ if params != nil {
176
+ paramsMap = params .AsMap ()
177
+ if params .NeedsEventualConsistencyHeaderFlag () {
178
+ if headers == nil {
179
+ headers = make (map [string ]string )
180
+ }
181
+ headers ["ConsistencyLevel" ] = "eventual"
173
182
}
174
- headers ["ConsistencyLevel" ] = "eventual"
175
183
}
176
184
177
- if req , err := NewRequest (ctx , http .MethodGet , endpoint , nil , params . AsMap () , headers ); err != nil {
185
+ if req , err := NewRequest (ctx , http .MethodGet , endpoint , nil , paramsMap , headers ); err != nil {
178
186
return nil , err
179
187
} else {
180
188
return s .Send (req )
@@ -183,7 +191,11 @@ func (s *restClient) Get(ctx context.Context, path string, params query.Params,
183
191
184
192
func (s * restClient ) Patch (ctx context.Context , path string , body interface {}, params query.Params , headers map [string ]string ) (* http.Response , error ) {
185
193
endpoint := s .api .ResolveReference (& url.URL {Path : path })
186
- if req , err := NewRequest (ctx , http .MethodPatch , endpoint , body , params .AsMap (), headers ); err != nil {
194
+ paramsMap := make (map [string ]string )
195
+ if params != nil {
196
+ paramsMap = params .AsMap ()
197
+ }
198
+ if req , err := NewRequest (ctx , http .MethodPatch , endpoint , body , paramsMap , headers ); err != nil {
187
199
return nil , err
188
200
} else {
189
201
return s .Send (req )
@@ -192,7 +204,11 @@ func (s *restClient) Patch(ctx context.Context, path string, body interface{}, p
192
204
193
205
func (s * restClient ) Post (ctx context.Context , path string , body interface {}, params query.Params , headers map [string ]string ) (* http.Response , error ) {
194
206
endpoint := s .api .ResolveReference (& url.URL {Path : path })
195
- if req , err := NewRequest (ctx , http .MethodPost , endpoint , body , params .AsMap (), headers ); err != nil {
207
+ paramsMap := make (map [string ]string )
208
+ if params != nil {
209
+ paramsMap = params .AsMap ()
210
+ }
211
+ if req , err := NewRequest (ctx , http .MethodPost , endpoint , body , paramsMap , headers ); err != nil {
196
212
return nil , err
197
213
} else {
198
214
return s .Send (req )
@@ -201,7 +217,11 @@ func (s *restClient) Post(ctx context.Context, path string, body interface{}, pa
201
217
202
218
func (s * restClient ) Put (ctx context.Context , path string , body interface {}, params query.Params , headers map [string ]string ) (* http.Response , error ) {
203
219
endpoint := s .api .ResolveReference (& url.URL {Path : path })
204
- if req , err := NewRequest (ctx , http .MethodPost , endpoint , body , params .AsMap (), headers ); err != nil {
220
+ paramsMap := make (map [string ]string )
221
+ if params != nil {
222
+ paramsMap = params .AsMap ()
223
+ }
224
+ if req , err := NewRequest (ctx , http .MethodPost , endpoint , body , paramsMap , headers ); err != nil {
205
225
return nil , err
206
226
} else {
207
227
return s .Send (req )
0 commit comments