Sha256: 67a7c4001bdfa5456e9c746809a06f14d08777035d381b9bdacbfd1c32db8d21
Contents?: true
Size: 633 Bytes
Versions: 10
Compression:
Stored size: 633 Bytes
Contents
module DigitalOcean class AuthenticationMiddleware < Faraday::Middleware extend Forwardable def_delegators :'Faraday::Utils', :parse_query, :build_query def initialize(app, client_id, api_key) @client_id = client_id @api_key = api_key super(app) end def call(env) params = { 'client_id' => @client_id, 'api_key' => @api_key }.update query_params(env[:url]) env[:url].query = build_query params @app.call(env) end def query_params(url) if url.query.nil? or url.query.empty? {} else parse_query url.query end end end end
Version data entries
10 entries across 10 versions & 1 rubygems