class DigitalOcean::AuthenticationMiddleware

Public Class Methods

new(app, client_id, api_key) click to toggle source
Calls superclass method
# 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

Public Instance Methods

call(env) click to toggle source
# 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
query_params(url) click to toggle source
# 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