3
\$\begingroup\$

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.

\$\endgroup\$
1
  • 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\$ Commented Feb 28, 2017 at 15:23

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.