REST with ruby?

Are there any good recommendations on how to send PUT / DELETE / POST / GET with ruby?

I looked at Net :: HTTP.

Is this library capable of all four methods? I could not find how to send using PUT.

Are there other good libraries for all of these four methods?

+3
source share
3 answers

The simplest way is probably to use the remainder of the gem client . Then you can do something like

RestClient.get 'http://example.com/resource', {:params => {:id => 50, 'foo' => 'bar'}}

EDIT: The URL has changed to a more modern one.

+3
source

HTTParty. RESTful, JSON ..

+4

HTTP- net/http. - HTTParty , faraday.

net/http , - :

require 'net/http'

http = Net::HTTP.new('api.host.ca')

# GET, DELETE
http.get('/path')
http.delete('/path')

# POST, PUT
http.put('/path', body_data)
http.post('/path', body_data)

body_data - , . , HTTP-;

# GET, with Headers
http.get('/path', { 'Content-Type' => 'application/json' })

, , .

, API Google Ruby, .

0

Source: https://habr.com/ru/post/1762053/


All Articles