Class: DigitalOcean::AuthenticationMiddleware
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- DigitalOcean::AuthenticationMiddleware
- Extended by:
- Forwardable
- Defined in:
- lib/digital_ocean/authentication_middleware.rb
Instance Method Summary (collapse)
- - (Object) call(env)
-
- (AuthenticationMiddleware) initialize(app, client_id, api_key)
constructor
A new instance of AuthenticationMiddleware.
- - (Object) query_params(url)
Constructor Details
- (AuthenticationMiddleware) initialize(app, client_id, api_key)
A new instance of AuthenticationMiddleware
6 7 8 9 10 11 |
# File 'lib/digital_ocean/authentication_middleware.rb', line 6 def initialize(app, client_id, api_key) @client_id = client_id @api_key = api_key super(app) end |
Instance Method Details
- (Object) call(env)
13 14 15 16 17 18 19 |
# File 'lib/digital_ocean/authentication_middleware.rb', line 13 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 |
- (Object) query_params(url)
21 22 23 24 25 26 27 |
# File 'lib/digital_ocean/authentication_middleware.rb', line 21 def query_params(url) if url.query.nil? or url.query.empty? {} else parse_query url.query end end |