lib/toxiproxy.rb in toxiproxy-1.0.2 vs lib/toxiproxy.rb in toxiproxy-1.0.3

- old
+ new

@@ -29,10 +29,12 @@ def_delegators :all, *ProxyCollection::METHODS # Re-enables all proxies and disables all toxics. def self.reset request = Net::HTTP::Post.new("/reset") + request["Content-Type"] = "application/json" + response = http_request(request) assert_response(response) self end @@ -142,10 +144,11 @@ end # Disables a Toxiproxy. This will drop all active connections and stop the proxy from listening. def disable request = Net::HTTP::Post.new("/proxies/#{name}") + request["Content-Type"] = "application/json" hash = {enabled: false} request.body = hash.to_json response = http_request(request) @@ -154,10 +157,11 @@ end # Enables a Toxiproxy. This will cause the proxy to start listening again. def enable request = Net::HTTP::Post.new("/proxies/#{name}") + request["Content-Type"] = "application/json" hash = {enabled: true} request.body = hash.to_json response = http_request(request) @@ -168,9 +172,10 @@ # Create a Toxiproxy, proxying traffic from `@listen` (optional argument to # the constructor) to `@upstream`. `#down` `#upstream` or `#downstream` can at any time alter the health # of this connection. def create request = Net::HTTP::Post.new("/proxies") + request["Content-Type"] = "application/json" hash = {upstream: upstream, name: name, listen: listen, enabled: enabled} request.body = hash.to_json response = http_request(request)