Skip to content

Use PATCH not POST when enable/disabling toxiproxy#186

Merged
brendo merged 3 commits into
mainfrom
chore_use-patch-not-post
Aug 26, 2025
Merged

Use PATCH not POST when enable/disabling toxiproxy#186
brendo merged 3 commits into
mainfrom
chore_use-patch-not-post

Conversation

@brendo
Copy link
Copy Markdown
Contributor

@brendo brendo commented Aug 18, 2025

Calls to proxies/{name} are currently going via POST which is triggering log output like:

{"level":"warn","request_id":"d2h9e85ctoqc73edkk0g","caller":"api.go:299","time":"2025-08-18T02:59:44Z","message":"ProxyUpdate: HTTP method POST is depercated. Use HTTP PATCH instead."}

This log is being emitted from Toxiproxy itself:

https://github.com/Shopify/toxiproxy/blob/6caf93523ef11fe7a546457b8d4114a1a634510e/api.go#L296-L300

To remove the log, this PR changes Toxiproxy.enable/Toxiproxy.disable to use PATCH instead of POST.

@brendo brendo requested review from a team, SheldonNunes, keisku and shopifyshuhei and removed request for a team August 18, 2025 03:52
Comment thread README.md Outdated
Comment thread lib/toxiproxy.rb
def version_string
return @version_string if @version_string

version_response = self.class.version
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just so i'm understanding this correctly - self.class.version contains a JSON blob that it gets from the server?

Copy link
Copy Markdown
Contributor Author

@brendo brendo Aug 26, 2025

Choose a reason for hiding this comment

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

Yeah! It turns out Toxiproxy.version is already exposed. This method will hit the underlying toxiproxy server's /version endpoint and return the result as a string.

def version
return false unless running?
request = Net::HTTP::Get.new("/version")
response = http_request(request)
assert_response(response)
response.body
end

That return will be a JSON blob, and while I wanted to parse and extract version from it all there that'd be a breaking change for anyone who is already doing that work. It's probably something we could change in a major release because while folks might be doing that, I think they'd prefer if the library did it for them :D

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Got it!

@brendo brendo merged commit ae9e3dc into main Aug 26, 2025
8 checks passed
@brendo brendo deleted the chore_use-patch-not-post branch August 26, 2025 03:01
@iandelahorne
Copy link
Copy Markdown

@brendo we should cut a new release with this as last one is over 3 years old 😬

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.

3 participants