lib/rapidash/http_client.rb in rapidash-0.0.2 vs lib/rapidash/http_client.rb in rapidash-0.0.3
- old
+ new
@@ -1,11 +1,11 @@
require 'faraday'
module Rapidash
module HTTPClient
- attr_accessor :site
+ attr_accessor :site, :extension
attr_writer :connection
def site=(value)
@connection = nil
@site = value
@@ -14,9 +14,10 @@
def connection
@connection ||= Faraday.new(site)
end
def request(verb, url, options = {})
+ url = "#{url}.#{extension}" if extension
url = connection.build_url(url, options[:params]).to_s
response = connection.run_request(verb, url, options[:body], options[:header])
# "foo"[0] does not work in 1.8.7, "foo"[0,1] is required
case response.status.to_s[0,1]