Sha256: 24d59a21273ad05d5bb0692db0c8dbc412194df54361a5f8ed4ab7a9eb98f977

Contents?: true

Size: 1.27 KB

Versions: 5

Compression:

Stored size: 1.27 KB

Contents

# encoding: UTF-8
require_relative 'base_middleware'

module GoodData
  module Bricks
    class GoodDataMiddleware < Bricks::Middleware
      def call(params)
        logger = params['GDC_LOGGER']
        token_name = 'GDC_SST'
        protocol_name = 'CLIENT_GDC_PROTOCOL'
        server_name = 'CLIENT_GDC_HOSTNAME'
        project_id = params['GDC_PROJECT_ID']

        server = if params[protocol_name] && params[server_name]
                   "#{params[protocol_name]}://#{params[server_name]}"
                 end

        client = if params['GDC_USERNAME'].nil? || params['GDC_PASSWORD'].nil?
                   puts "Connecting with SST to server #{server}"
                   fail 'SST (SuperSecureToken) not present in params' if params[token_name].nil?
                   GoodData.connect(sst_token: params[token_name], server: server)
                 else
                   puts "Connecting as #{params['GDC_USERNAME']} to server #{server}"
                   GoodData.connect(params['GDC_USERNAME'], params['GDC_PASSWORD'], server: server)
                 end
        project = client.projects(project_id)
        GoodData.project = project
        GoodData.logger = logger
        @app.call(params.merge('GDC_GD_CLIENT' => client, 'gdc_project' => project))
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gooddata-0.6.20 lib/gooddata/bricks/middleware/gooddata_middleware.rb
gooddata-0.6.19 lib/gooddata/bricks/middleware/gooddata_middleware.rb
gooddata-0.6.18 lib/gooddata/bricks/middleware/gooddata_middleware.rb
gooddata-0.6.17 lib/gooddata/bricks/middleware/gooddata_middleware.rb
gooddata-0.6.16 lib/gooddata/bricks/middleware/gooddata_middleware.rb