we get a ton of these little posts, but i genuinely thought someone
might find this useful (i certainly do):
i’ve had to do more than my fair share of work with net/http and it
sucks. because most of us spend more time writing web apps/services
than we do consuming them in ruby, we have beautiful DSLs like sinatra
to help us. it’s about time we had the same for client work.
example:
get ‘www.google.com’
=> #<Net::HTTPOK 200 OK readbody=true>
more complicated example (with custom headers and such):
res = get ‘www.google.com’ do |req|
req.header “x-some-key”, “some value”
req.header “x-some-other-key”, “some other value”
end
=> #<Net::HTTPOK 200 OK readbody=true>
you get the idea. feedback welcome. really, i mean that. lay in- i
can take it
oh, one important note: unfortunately, this stomps all over sinatra
(obviously) so they can’t be used together- for now.
tom