Class: HttpBaseline::Adapter::Rest
- Inherits:
-
HttpBaseline::Abstract
- Object
- Evf::Abstract
- HttpBaseline::Abstract
- HttpBaseline::Adapter::Rest
- Defined in:
- lib/http_baseline/adapter/rest.rb,
lib/http_baseline/adapter/rest/response/logger.rb
Defined Under Namespace
Modules: Response
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #attach_extension(other_module) ⇒ Object
- #delete(url, *args) ⇒ Object
- #get(url, *args) ⇒ Object
-
#initialize(config) ⇒ Rest
constructor
A new instance of Rest.
- #post(url, body = nil, *args) ⇒ Object
- #put(url, body = nil, *args) ⇒ Object
Constructor Details
#initialize(config) ⇒ Rest
Returns a new instance of Rest.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/http_baseline/adapter/rest.rb', line 11 def initialize(config) super @client = Faraday.new do |pipe| pipe.use Faraday::Request::UrlEncoded pipe.use FaradayMiddleware::EncodeJson pipe.use FaradayMiddleware::FollowRedirects pipe.use FaradayMiddleware::Mashify pipe.use Response::Logger pipe.url_prefix = @uri end headers[:user_agent] = 'WS v%s' % HttpBaseline::VERSION end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
9 10 11 |
# File 'lib/http_baseline/adapter/rest.rb', line 9 def uri @uri end |
Instance Method Details
#attach_extension(other_module) ⇒ Object
25 26 27 |
# File 'lib/http_baseline/adapter/rest.rb', line 25 def attach_extension(other_module) @client.use other_module end |
#delete(url, *args) ⇒ Object
40 41 42 |
# File 'lib/http_baseline/adapter/rest.rb', line 40 def delete(url, *args) @client.delete(configured_path(url), *args) end |
#get(url, *args) ⇒ Object
30 31 32 |
# File 'lib/http_baseline/adapter/rest.rb', line 30 def get(url, *args) @client.get(configured_path(url), *args) end |
#post(url, body = nil, *args) ⇒ Object
35 36 37 |
# File 'lib/http_baseline/adapter/rest.rb', line 35 def post(url, body = nil, *args) @client.post(configured_path(url), body, *args) end |
#put(url, body = nil, *args) ⇒ Object
44 45 46 |
# File 'lib/http_baseline/adapter/rest.rb', line 44 def put(url, body = nil, *args) @client.put(configured_path(url), body, *args) end |