Asynchronous HTTP Requests using Threads
achetepe
requires Ruby 1.9 or later.
Install dependencies using dep
is easy as run:
dep install
Start test server
rake test:start_server
Run tests
rake
Stop test server
rake test:stop_server
As simple as
$ gem install achetepe
achetepe
makes an HTTP request to run in background using Threads and when you get a response, it will execute a block (a.k.a callback function)
Achetepe.get('https://github.com/emancu/achetepe') do |response|
puts response
end
# => #<Thread:0x007fd2b413b530 sleep>
# => #<Net::HTTPOK:0x007fd2b5959f68>
Achetepe.post('http://www.example.com/search.cgi', q: 'ruby') do |response|
puts response
end
# => #<Thread:0x007fc8c605ac80 sleep>
# => #<Net::HTTPBadGateway:0x007fc8c4bc2ca0>
Coming soon..