Search code examples
rubyruby-on-rails-3restrest-client

How to make an async POST request in Ruby using RestClient


Can we make an asynchronous POST request to a resource in Ruby using the RestClient library ( https://github.com/archiloque/rest-client )?


Solution

  • If by "asyncronous POST request" you mean "fire-and-forget" kind of request, then you can execute it on another thread.

    Thread.new do
      # do your request here
    end
    

    Note, however, that not all Ruby implementations use real concurrent threads. See this topic for more details.