Sha256: 04a8dc0778b412d2f62515337ff5a95ecf5c3cd4e231ed7aec4e272c18ec51c3

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

# encoding: utf-8

require 'github_api/response'
require 'github_api/response/mashify'
require 'github_api/response/jsonize'
require 'github_api/response/atom_parser'
require 'github_api/response/raise_error'
require 'github_api/response/header'
require 'github_api/response/follow_redirects'

module Github
  class Middleware
    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
  end # Middleware
end # Github

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
github_api-0.17.0 lib/github_api/middleware.rb
github_api-0.16.0 lib/github_api/middleware.rb