Sha256: fedce6931e81a5474a6a8d4e395f9db23d8c10e77de6814224eebde5bc1837e3

Contents?: true

Size: 658 Bytes

Versions: 3

Compression:

Stored size: 658 Bytes

Contents

require 'rest-core/middleware'

class RestCore::Oauth2Header
  def self.members; [:access_token_type, :access_token]; end
  include RestCore::Middleware

  def call env, &k
    start_time = Time.now
    headers = {'Authorization' =>
                 "#{access_token_type(env)} #{access_token(env)}"}.
                merge(env[REQUEST_HEADERS]) if access_token(env)

    event = Event::WithHeader.new(Time.now - start_time,
              "Authorization: #{headers['Authorization']}") if headers

    app.call(log(env.merge(REQUEST_HEADERS => headers ||
                                              env[REQUEST_HEADERS]), event),
             &k)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rest-core-2.1.2 lib/rest-core/middleware/oauth2_header.rb
rest-core-2.1.1 lib/rest-core/middleware/oauth2_header.rb
rest-core-2.1.0 lib/rest-core/middleware/oauth2_header.rb