Module: Sb::Http
- Defined in:
- lib/sb/http.rb,
lib/sb/http/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"0.1.1"
Class Method Summary collapse
Class Method Details
.get(url, opts = {start_opts: {use_ssl: true}}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sb/http.rb', line 12 def get url, opts={start_opts: {use_ssl: true}} uri = URI(url) req = Net::HTTP::Get.new(uri) res = Net::HTTP.start(uri.hostname, uri.port, opts[:start_opts]) {|http| http.request(req) } case res.content_type when 'text/html' res.body when 'application/json' JSON.parse res.body else res.body end end |