@@ -181,23 +181,23 @@ func (cb *CircuitBreaker) doRequest(ctx context.Context, method, path string, qu
181181 var err error
182182
183183 switch method {
184- case "GET" :
184+ case http . MethodGet :
185185 result , err = cb .executeWithCircuitBreaker (ctx , func (ctx context.Context ) (* http.Response , error ) {
186186 return cb .HTTP .GetWithHeaders (ctx , path , queryParams , headers )
187187 })
188- case "POST" :
188+ case http . MethodPost :
189189 result , err = cb .executeWithCircuitBreaker (ctx , func (ctx context.Context ) (* http.Response , error ) {
190190 return cb .HTTP .PostWithHeaders (ctx , path , queryParams , body , headers )
191191 })
192- case "PATCH" :
192+ case http . MethodPatch :
193193 result , err = cb .executeWithCircuitBreaker (ctx , func (ctx context.Context ) (* http.Response , error ) {
194194 return cb .HTTP .PatchWithHeaders (ctx , path , queryParams , body , headers )
195195 })
196- case "PUT" :
196+ case http . MethodPut :
197197 result , err = cb .executeWithCircuitBreaker (ctx , func (ctx context.Context ) (* http.Response , error ) {
198198 return cb .HTTP .PutWithHeaders (ctx , path , queryParams , body , headers )
199199 })
200- case "DELETE" :
200+ case http . MethodDelete :
201201 result , err = cb .executeWithCircuitBreaker (ctx , func (ctx context.Context ) (* http.Response , error ) {
202202 return cb .HTTP .DeleteWithHeaders (ctx , path , body , headers )
203203 })
@@ -211,50 +211,31 @@ func (cb *CircuitBreaker) doRequest(ctx context.Context, method, path string, qu
211211 return resp , err
212212}
213213
214- func (cb * CircuitBreaker ) Get (ctx context.Context , api string , queryParams map [string ]interface {}) (* http.Response , error ) {
215- return cb .doRequest (ctx , "GET" , api , queryParams , nil , nil )
216- }
217214func (cb * CircuitBreaker ) GetWithHeaders (ctx context.Context , path string , queryParams map [string ]interface {},
218215 headers map [string ]string ) (* http.Response , error ) {
219- return cb .doRequest (ctx , "GET" , path , queryParams , nil , headers )
220- }
221-
222- // Post is a wrapper for doRequest with the POST method.
223- func (cb * CircuitBreaker ) Post (ctx context.Context , path string , queryParams map [string ]interface {}, body []byte ) (* http.Response , error ) {
224- return cb .doRequest (ctx , "POST" , path , queryParams , body , nil )
216+ return cb .doRequest (ctx , http .MethodGet , path , queryParams , nil , headers )
225217}
226218
227219// PostWithHeaders is a wrapper for doRequest with the POST method and headers.
228220func (cb * CircuitBreaker ) PostWithHeaders (ctx context.Context , path string , queryParams map [string ]interface {},
229221 body []byte , headers map [string ]string ) (* http.Response , error ) {
230- return cb .doRequest (ctx , "POST" , path , queryParams , body , headers )
231- }
232-
233- // Patch is a wrapper for doRequest with the PATCH method.
234- func (cb * CircuitBreaker ) Patch (ctx context.Context , path string , queryParams map [string ]interface {},
235- body []byte ) (* http.Response , error ) {
236- return cb .doRequest (ctx , "PATCH" , path , queryParams , body , nil )
222+ return cb .doRequest (ctx , http .MethodPost , path , queryParams , body , headers )
237223}
238224
239225// PatchWithHeaders is a wrapper for doRequest with the PATCH method and headers.
240226func (cb * CircuitBreaker ) PatchWithHeaders (ctx context.Context , path string , queryParams map [string ]interface {},
241227 body []byte , headers map [string ]string ) (* http.Response , error ) {
242- return cb .doRequest (ctx , "PATCH" , path , queryParams , body , headers )
228+ return cb .doRequest (ctx , http . MethodPatch , path , queryParams , body , headers )
243229}
244230
245231// PutWithHeaders is a wrapper for doRequest with the PUT method and headers.
246232func (cb * CircuitBreaker ) PutWithHeaders (ctx context.Context , path string , queryParams map [string ]interface {},
247233 body []byte , headers map [string ]string ) (* http.Response , error ) {
248- return cb .doRequest (ctx , "PUT" , path , queryParams , body , headers )
249- }
250-
251- // Delete is a wrapper for doRequest with the DELETE method.
252- func (cb * CircuitBreaker ) Delete (ctx context.Context , path string , body []byte ) (* http.Response , error ) {
253- return cb .doRequest (ctx , "DELETE" , path , nil , body , nil )
234+ return cb .doRequest (ctx , http .MethodPut , path , queryParams , body , headers )
254235}
255236
256237// DeleteWithHeaders is a wrapper for doRequest with the DELETE method and headers.
257238func (cb * CircuitBreaker ) DeleteWithHeaders (ctx context.Context , path string , body []byte , headers map [string ]string ) (
258239 * http.Response , error ) {
259- return cb .doRequest (ctx , "DELETE" , path , nil , body , headers )
240+ return cb .doRequest (ctx , http . MethodDelete , path , nil , body , headers )
260241}
0 commit comments