Last active
August 29, 2015 14:07
-
-
Save tkuchiki/02ba3c70abc76f8953d5 to your computer and use it in GitHub Desktop.
ruby の net/http で consul の status/leader の結果を取得する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'net/http' | |
require 'uri' | |
require 'json' | |
uri = URI.parse('http://127.0.0.1:8500/v1/status/leader') | |
http = Net::HTTP.new(uri.host, uri.port) | |
res = http.start { | |
http.get(uri.request_uri) | |
} | |
if res.code == '200' | |
result = res.body.delete('"') | |
else | |
result = nil | |
end | |
result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment