lib/rancher/api.rb in rancher-api-0.4.0 vs lib/rancher/api.rb in rancher-api-0.5.0
- old
+ new
@@ -2,10 +2,11 @@
require 'her'
require 'rancher/api/configuration'
require 'rancher/api/middlewares'
require 'rancher/api/version'
+require 'rancher/api/logger'
module Rancher
module Api
class << self
attr_writer :configuration
@@ -25,24 +26,26 @@
end
def self.configure
yield(configuration)
- Her::API.setup url: configuration.url do |c|
+ api = Her::API.setup url: configuration.url do |c|
# Request
c.request :json
c.use Her::Middleware::AcceptJSON
c.use Faraday::Request::BasicAuthentication, configuration.access_key, configuration.secret_key
# Response
c.use Rancher::Api::JsonParserMiddleware
c.use Her::Middleware::DefaultParseJSON
+ c.use Faraday::Response::Logger, ActiveSupport::Logger.new(STDOUT) if configuration.verbose
# Adapter
c.use Faraday::Adapter::NetHttp
end
require 'rancher/api/models'
+ api
end
end
end