Sha256: a9e70cec3c037299ff2198816b62a6eddfe25ea67b8ba251f3e62e199b9161c2

Contents?: true

Size: 963 Bytes

Versions: 1

Compression:

Stored size: 963 Bytes

Contents

require 'gooddata'

module GoodData::Bricks
  class GoodDataMiddleware < GoodData::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_USERANME" 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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gooddata-0.6.0.pre10 lib/gooddata/bricks/middleware/gooddata_middleware.rb