Class: Github::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/github_api/middleware.rb

Class Method Summary collapse

Class Method Details

.default(options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/github_api/middleware.rb', line 13

def self.default(options = {})
  api = options[:api]
  proc do |builder|
    builder.use Github::Request::Jsonize
    builder.use Faraday::Request::Multipart
    builder.use Faraday::Request::UrlEncoded
    builder.use Github::Request::OAuth2, api.oauth_token if api.oauth_token?
    builder.use Github::Request::BasicAuth, api.authentication if api.basic_authed?

    builder.use Github::Response::FollowRedirects if api.follow_redirects
    builder.use Faraday::Response::Logger if ENV['DEBUG']
    unless options[:raw]
      builder.use Github::Response::Mashify
      builder.use Github::Response::Jsonize
      builder.use Github::Response::AtomParser
    end
    if api.stack
      api.stack.call(builder)
    end
    builder.use Github::Response::RaiseError
    builder.adapter options[:adapter]
  end
end