Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

More client refactoring and cleanup #160

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

jmigueprieto
Copy link
Contributor

@jmigueprieto jmigueprieto commented Nov 6, 2024

Follow up of #159

Changes in this PR

  • Refactor code to set Accept and Content-Type headers.

@jmigueprieto jmigueprieto self-assigned this Nov 6, 2024
@jmigueprieto jmigueprieto changed the title (FIX) Refactor api client More api client refactoring and cleanup Nov 6, 2024
@jmigueprieto jmigueprieto changed the title More api client refactoring and cleanup More client refactoring and cleanup Nov 6, 2024
contentTypes := []string{}

// set Content-Type header
contentType := selectHeaderContentType(contentTypes)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This always return an empty contentType

// to determine the Content-Type header
contentTypes := []string{}
// set Content-Type header
contentType := selectHeaderContentType(contentTypes)
if contentType != "" {
	headerParams["Content-Type"] = contentType
}

So it doesn't really make sense.

And this is just setting to headerParams["Content-Type"] ="application/json"

// to determine the Content-Type header
contentTypes := []string{"application/json"}

// set Content-Type header
contentType := selectHeaderContentType(contentTypes)
if contentType != "" {
	headerParams["Content-Type"] = contentType
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And a similar thing happens with

// to determine the Accept header
headerAccepts := []string{"application/json"}

// set Accept header
headerAccept := selectHeaderAccept(headerAccepts)
if headerAccept != "" {
	headerParams["Accept"] = headerAccept
}

@jmigueprieto jmigueprieto marked this pull request as ready for review November 6, 2024 16:12
@jmigueprieto jmigueprieto requested review from v1r3n, c4lm and a team November 6, 2024 16:12
@jmigueprieto jmigueprieto merged commit 283f031 into main Nov 6, 2024
3 checks passed
@jmigueprieto jmigueprieto deleted the fix/refactoring-api-client-code branch November 6, 2024 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants