Skip to content

Refactor DoRequestV2 to DoRequest and add DoMultipartRequest #49

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions httpclient/httpclient_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"go.uber.org/zap"
)

// DoRequestV2 constructs and executes an HTTP request, choosing the execution path based on the idempotency of the HTTP method.
func (c *Client) DoRequestV2(method, endpoint string, body, out interface{}, log logger.Logger) (*http.Response, error) {
// DoRequest constructs and executes an HTTP request, choosing the execution path based on the idempotency of the HTTP method.
func (c *Client) DoRequest(method, endpoint string, body, out interface{}, log logger.Logger) (*http.Response, error) {
if IsIdempotentHTTPMethod(method) {
return c.executeRequestWithRetries(method, endpoint, body, out, log)
} else if IsNonIdempotentHTTPMethod(method) {
Expand Down Expand Up @@ -323,6 +323,7 @@ func (c *Client) handleSuccessResponse(resp *http.Response, out interface{}, log
// Note:
// The function assumes that retryable HTTP methods have been properly defined in the retryableHTTPMethods map.
// It is the caller's responsibility to close the response body when the request is successful to avoid resource leaks.
/*
func (c *Client) DoRequest(method, endpoint string, body, out interface{}, log logger.Logger) (*http.Response, error) {
// Auth Token validation check
valid, err := c.ValidAuthTokenCheck(log)
Expand Down Expand Up @@ -557,7 +558,7 @@ func (c *Client) DoRequest(method, endpoint string, body, out interface{}, log l
// TODO refactor to remove repition and to streamline error handling.
return nil, fmt.Errorf("an unexpected error occurred")
}

*/
// DoMultipartRequest creates and executes a multipart HTTP request. It is used for sending files
// and form fields in a single request. This method handles the construction of the multipart
// message body, setting the appropriate headers, and sending the request to the given endpoint.
Expand Down