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.

Jamal
35.2k13 gold badges134 silver badges238 bronze badges
asked Feb 28, 2017 at 4:16
\$\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

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.