Sha256: d30092f75b1d19b6293e9af72cc5c5211cbe9e77225ae511549cd6e18e0752ee

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

# encoding: UTF-8

require 'gooddata'

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 = 'GDC_PROTOCOL'
        server_name = 'GDC_HOSTNAME'
        project_id = params['GDC_PROJECT_ID']

        fail 'SST (SuperSecureToken) not present in params' if params[token_name].nil?
        server = if !params[protocol_name].empty? && !params[server_name].empty?
                   "#{params[protocol_name]}://#{params[server_name]}"
                 end

        fail 'GoodData username is missing. Expected param :GDC_USERNAME' if params['GDC_USERNAME'].nil?
        fail 'GoodData password is missing. Expected param :GDC_PASSWORD' if params['GDC_PASSWORD'].nil?

        GoodData.connect(params['GDC_USERNAME'], params['GDC_PASSWORD'], :server => server)
        GoodData.logger = logger
        GoodData.with_project(project_id) do |p|
          @app.call(params)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gooddata-0.6.7 lib/gooddata/bricks/middleware/gooddata_middleware.rb
gooddata-0.6.6 lib/gooddata/bricks/middleware/gooddata_middleware.rb
gooddata-0.6.5 lib/gooddata/bricks/middleware/gooddata_middleware.rb
gooddata-0.6.4 lib/gooddata/bricks/middleware/gooddata_middleware.rb
gooddata-0.6.3 lib/gooddata/bricks/middleware/gooddata_middleware.rb
gooddata-0.6.2 lib/gooddata/bricks/middleware/gooddata_middleware.rb