Skip to content

Prevent mutating the client base URL#1

Open
SteppingHat wants to merge 3 commits intosmsglobal:mainfrom
SteppingHat:main
Open

Prevent mutating the client base URL#1
SteppingHat wants to merge 3 commits intosmsglobal:mainfrom
SteppingHat:main

Conversation

@SteppingHat
Copy link
Copy Markdown

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
Copy Markdown
Author

Bump

@SteppingHat
Copy link
Copy Markdown
Author

Buuuuump please 😄

@SteppingHat
Copy link
Copy Markdown
Author

@spcheema bump please - we need this fix

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