Class: Faraday::Request::Authorization

### Home Classes Methods

### In Files

- lib/faraday/request/authorization.rb

### Parent

Faraday::Middleware

### Methods

- ::build_hash
- ::header
- ::new
- #call

### Class/Module Index

Quicksearch

- Faraday
- Faraday::Adapter
- Faraday::Adapter::EMHttp
- Faraday::Adapter::EMHttp::Manager
- Faraday::Adapter::EMHttp::Options
- Faraday::Adapter::EMSynchrony
- Faraday::Adapter::EMSynchrony::ParallelManager
- Faraday::Adapter::Excon
- Faraday::Adapter::HTTPClient
- Faraday::Adapter::NetHttp
- Faraday::Adapter::NetHttpPersistent
- Faraday::Adapter::Parallelism
- Faraday::Adapter::Patron
- Faraday::Adapter::Rack
- Faraday::Adapter::Test
- Faraday::Adapter::Test::Stub
- Faraday::Adapter::Test::Stubs
- Faraday::Adapter::Test::Stubs::NotFound
- Faraday::Adapter::Typhoeus
- Faraday::AutoloadHelper
- Faraday::ClientError
- Faraday::CompositeReadIO
- Faraday::Connection
- Faraday::ConnectionFailed
- Faraday::ConnectionOptions
- Faraday::Env
- Faraday::Error
- Faraday::FlatParamsEncoder
- Faraday::Middleware
- Faraday::MiddlewareRegistry
- Faraday::MissingDependency
- Faraday::NestedParamsEncoder
- Faraday::Options
- Faraday::ParsingError
- Faraday::ProxyOptions
- Faraday::RackBuilder
- Faraday::RackBuilder::Handler
- Faraday::RackBuilder::StackLocked
- Faraday::Request
- Faraday::Request::Authorization
- Faraday::Request::BasicAuthentication
- Faraday::Request::Instrumentation
- Faraday::Request::Instrumentation::Options
- Faraday::Request::Multipart
- Faraday::Request::Retry
- Faraday::Request::Retry::Options
- Faraday::Request::TokenAuthentication
- Faraday::Request::UrlEncoded
- Faraday::RequestOptions
- Faraday::ResourceNotFound
- Faraday::Response
- Faraday::Response::Logger
- Faraday::Response::Middleware
- Faraday::Response::RaiseError
- Faraday::SSLError
- Faraday::SSLOptions
- Faraday::TimeoutError
- Faraday::Utils
- Faraday::Utils::Headers
- Faraday::Utils::ParamsHash
- EmHttpSslPatch
- Object

No matching classes.

# Faraday::Request::Authorization

### Constants

KEY

### Public Class Methods

build_hash(type, hash) click to toggle source

Internal

    # File lib/faraday/request/authorization.rb, line 18
    def self.build_hash(type, hash)
      offset = KEY.size + type.size + 3
      comma = ",\n#{' ' * offset}"
      values = []
      hash.each do |key, value|
        values << "#{key}=#{value.to_s.inspect}"
      end
      "#{type} #{values * comma}"
    end

header(type, token) click to toggle source

Public

    # File lib/faraday/request/authorization.rb, line 6
    def self.header(type, token)
      case token
      when String, Symbol
        "#{type} #{token}"
      when Hash
        build_hash(type.to_s, token)
      else
        raise ArgumentError, "Can't build an Authorization #{type} header from #{token.inspect}"
      end
    end

new(app, type, token) click to toggle source

    # File lib/faraday/request/authorization.rb, line 28
    def initialize(app, type, token)
      @header_value = self.class.header(type, token)
      super(app)
    end

### Public Instance Methods

call(env) click to toggle source

Public

    # File lib/faraday/request/authorization.rb, line 34
    def call(env)
      unless env.request_headers[KEY]
        env.request_headers[KEY] = @header_value
      end
      @app.call(env)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.