\$\begingroup\$
\$\endgroup\$
1
I had a curl command which I converted using this.
This is the Ruby script:
rabbitmqctl_url = CONFIG['rabbitmqctl']['url']
rabbitmqctl_user = CONFIG['rabbitmqctl']['username']
rabbitmqctl_password = CONFIG['rabbitmqctl']['password']
uri = URI.parse("#{rabbitmqctl_url}/api/queues")
request = Net::HTTP::Get.new(uri)
request.basic_auth(rabbitmqctl_user, rabbitmqctl_password)
req_options = { use_ssl: uri.scheme == 'https' }
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(request)
end
puts response.body
This is the curl command:
curl -u username:password http:localhost 15672/api/queue
This code is very lengthy.
Jamal
35.2k13 gold badges134 silver badges238 bronze badges
-
1\$\begingroup\$ You might want to look into gems that wrap some or all of this stuff in a simpler API, like httparty. With that you should be able to get closer to the simplicity of the curl command. The basic Ruby API is (on purpose) very bare bones, and doesn't try to be clever about things \$\endgroup\$Flambino– Flambino2017年02月28日 15:23:30 +00:00Commented Feb 28, 2017 at 15:23
lang-rb