Faradayのインストール
$gem install faraday
#サンプル
http_clinet.rb
reqiure 'faraday'
connection = Faraday::Connection.new(:url => 'http://localhost:3000') do | builder |
# リクエストパラメータをURLエンコードする
builder.use Faraday::Request::UrlEncoded
# アダプターにNetHttpを使用する
builder.use Faraday::Adapter::NetHttp
end
# GET http://localhost:3000/api/foo を送信
response = connection.get('/api/foo')
# PUT http://localhost:3000/api/bar を送信
# response = connection.put('/api/bar', {:bar => "barbar"})
# POST http://localhost:3000/api/baz を送信
# response = connection.post('/api/baz', {:baz => "bazbaz"})
# DELETE http://localhost:3000/api/qux を送信
# response = connection.delete('/api/qux')
p response