Sha256: 56fb672482ba67c7590e458928ee1b342fed9ce320dcb64a0c4f81b6e4a215e0

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 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'

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 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

7 entries across 7 versions & 1 rubygems

Version Path
github_api-0.15.0 lib/github_api/middleware.rb
github_api-0.14.5 lib/github_api/middleware.rb
github_api-0.14.4 lib/github_api/middleware.rb
github_api-0.14.3 lib/github_api/middleware.rb
github_api-0.14.2 lib/github_api/middleware.rb
github_api-0.14.1 lib/github_api/middleware.rb
github_api-0.14.0 lib/github_api/middleware.rb