Daruma
The very simple HTTP client.
Requirements
- Ruby 2.4.0 or higher
Usage
Get
require 'daruma'
client = Daruma::Client.new('https://example.co.jp/')
params = {a: 1, b: 2}
response = client.get('/', params: params)
Post
require 'daruma'
client = Daruma::Client.new('https://example.co.jp/')
params = {a: 1, b: 2}
response = client.post('/', params: params)
Put
require 'daruma'
client = Daruma::Client.new('https://example.co.jp/')
params = {a: 1, b: 2}
response = client.put('/', params: params)
Patch
require 'daruma'
client = Daruma::Client.new('https://example.co.jp/')
params = {a: 1, b: 2}
response = client.patch('/', params: params)
Delete
require 'daruma'
client = Daruma::Client.new('https://example.co.jp/')
params = {a: 1, b: 2}
response = client.delete('/', params: params)
Option
Retry
This code is that it is executing 4 times at 5 second intervals when error is occured.
require 'daruma'
client = Daruma::Client.new('https://example.co.jp/')
response = client.get('/', tries: 3, sleep_seconds: 5)