lib/gooddata/bricks/middleware/gooddata_middleware.rb in gooddata-0.6.0.pre3 vs lib/gooddata/bricks/middleware/gooddata_middleware.rb in gooddata-0.6.0.pre4

- old
+ new

@@ -1,22 +1,27 @@ require 'gooddata' -class GoodDataMiddleware < GoodData::Bricks::Middleware +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_SERVER + def call(params) + logger = params[:gdc_logger] + token_name = :GDC_SST + protocol_name = :GDC_PROTOCOL + server_name = :GDC_SERVER + project_id = params[:GDC_PROJECT_ID] - fail "SST (SuperSecureToken) not present in params" if params[token_name].nil? - logger.info "Connecting to GD with SST" - server = if !params[protocol_name].empty? && !params[server_name].empty? - params[protocol_name] + "://" + params[server_name] + fail "SST (SuperSecureToken) not present in params" if params[token_name].nil? + logger.info "Connecting to GD with SST" + server = if !params[protocol_name].empty? && !params[server_name].empty? + params[protocol_name] + "://" + params[server_name] + end + + GoodData.connect_with_sst(params[token_name], {:server => server}) + GoodData.logger = logger + GoodData.with_project(project_id) do |p| + @app.call(params) + end end - GoodData.connect_with_sst(params[token_name], {:server => server}) - GoodData.logger = logger - @app.call(params) end - -end +end \ No newline at end of file