Sha256: c40809c69803e626feacd91f5f6c3ec74fd6474c6d63e071b1e3bc73f2083893
Contents?: true
Size: 1.9 KB
Versions: 1
Compression:
Stored size: 1.9 KB
Contents
# encoding: UTF-8 # # Copyright (c) 2010-2015 GoodData Corporation. All rights reserved. # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. require_relative 'base_middleware' module GoodData module Bricks class GoodDataMiddleware < Bricks::Middleware DEFAULT_PROTOCOL = 'https' DEFAULT_HOSTNAME = 'secure.gooddata.com' def call(params) # Convert possible jruby hash to plain hash params = params.to_hash # Transform keys params = GoodData::Helpers.deep_stringify_keys(params) # Set logger logger = params['GDC_LOGGER'] GoodData.logger = logger server = "#{params['CLIENT_GDC_PROTOCOL'] || DEFAULT_PROTOCOL}://#{params['CLIENT_GDC_HOSTNAME'] || DEFAULT_HOSTNAME}" opts = { server: server, verify_ssl: params['GDC_VERIFY_SSL'].to_b, username: params['GDC_USERNAME'], password: params['GDC_PASSWORD'], sst_token: params['GDC_SST'] } # Connect Client client = GoodData.connect(opts) opts = params['development_client'] development_client = if opts GoodData.connect(GoodData::Helpers.deep_symbolize_keys(opts)) else client end new_params = { 'GDC_GD_CLIENT' => client, 'development_client' => development_client } if params['GDC_PROJECT_ID'] new_params['gdc_project'] = GoodData.project = client.projects(params['GDC_PROJECT_ID']) end returning_value = @app.call(params.merge(new_params)) begin client.disconnect rescue puts 'Tried to disconnect. Was unsuccessful. Proceeding anyway.' end returning_value end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gooddata-bricks-0.8.0 | lib/gooddata/bricks/middleware/gooddata_middleware.rb |