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

Feature/refactor request builder #27

Merged
merged 22 commits into from
Mar 7, 2024

Conversation

gdeandradero
Copy link
Collaborator

@gdeandradero gdeandradero commented Mar 4, 2024

Removes options from baseclient, options are not so useful in that case because our baseclient should not have other configurations. This PR merges baseclient content with httpclient already that in our cases they have similar purposes (build request before sent to the Requester implementation).

@gdeandradero gdeandradero marked this pull request as ready for review March 5, 2024 12:40
pkg/internal/httpclient/helper.go Outdated Show resolved Hide resolved
pkg/internal/httpclient/helper.go Outdated Show resolved Hide resolved
pkg/internal/httpclient/helper.go Outdated Show resolved Hide resolved
pkg/internal/httpclient/helper.go Outdated Show resolved Hide resolved
pkg/payment/search_request.go Outdated Show resolved Hide resolved
return nil
}

func checkReplaces(pathURL string) error {

Choose a reason for hiding this comment

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

Usando o package regexp essa função não é necessária:

const pathParamRegexp = regexp.MustCompile(`{[^{}]*}`)
matches := pathParamRegexp.FindAllString(pathURL, -1)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

boa, feito!

pathURL := req.URL.Path

for k, v := range params {
pathParam := fmt.Sprintf("{%s}", k)

Choose a reason for hiding this comment

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

Só para conhecimento, Sprintf não tem uma boa performance.
strings.Join e usar + é mais performático. Como é uma concatenação bem simlpes acredito que não precisa usar Sprintf.

Suggested change
pathParam := fmt.Sprintf("{%s}", k)
pathParam := "{"+k+"}"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

feito!

@gdeandradero gdeandradero merged commit c76f053 into main Mar 7, 2024
2 checks passed
@gdeandradero gdeandradero deleted the feature/refactor-request-builder branch March 7, 2024 11:34
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.

4 participants