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

Prevent mutating the client base URL #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

SteppingHat
Copy link

In instances where a single use of the client is maintained throughout the lifetime of an application, there are operations that mutate the state of the client making it unusable for future requests.

For example, when sending three SMS messages a minute apart from each other, the log output shows the following:

{"level":"debug","REST CLIENT":"Do","time":"2024-06-20T18:37:00+10:00","message":"Sending POST request to https://api.smsglobal.com/v2/sms"}
...
{"level":"debug","REST CLIENT":"Do","time":"2024-06-20T18:38:00+10:00","message":"Sending POST request to https://api.smsglobal.com/v2/sms/sms"}
...
{"level":"debug","REST CLIENT":"Do","time":"2024-06-20T18:39:00+10:00","message":"Sending POST request to https://api.smsglobal.com/v2/sms/sms/sms"}

The issue is that when appending the path to the baseURL, it mutates the baseURL.

// append path to existing path "/v2"
c.BaseURL.Path = p.Join(c.BaseURL.Path, rel.Path)

This PR changes the way URL's are generated so that they are no longer mutating the client's BaseURL object.
Instead, it now creates it's own object used to create a request.

@SteppingHat
Copy link
Author

Bump

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.

1 participant