Class: RestPack::Web::App
- Inherits:
-
Object
- Object
- RestPack::Web::App
- Defined in:
- lib/restpack-web/app.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ App
constructor
A new instance of App.
Constructor Details
#initialize(app, options = {}) ⇒ App
Returns a new instance of App.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/restpack-web/app.rb', line 6 def initialize(app, = {}) p "RestPack::Web::App.initialize" @app = app [:core_domain] ||= ENV['RESTPACK_CORE_SERVICE'] [:access_key] ||= ENV['RESTPACK_ACCESS_KEY'] p "RestPack::Web::App.initialize: core_domain #{[:core_domain]}" @options = unless [:core_domain] || [:access_key] p "[WARNING] Missing RestPack configuration" else @core_cache = RestPack::Core::Client::Cache.create([:core_domain], [:access_key]) end end |
Instance Method Details
#call(env) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/restpack-web/app.rb', line 23 def call(env) env[:restpack] ||= {} #TODO: GJ: ignore requests with a file extension request = Rack::Request.new(env) channel = @core_cache.get_channel(request.host) domain = channel.get_domain_by_host(request.host) env[:restpack][:request] = request env[:restpack][:host] = request.host env[:restpack][:channel] = channel env[:restpack][:application] = domain.application env[:restpack][:domain] = domain env[:restpack][:configurations] = @core_cache.configurations env[:restpack][:services] = @core_cache.get_configuration_value('services', []) add_user env @app.call(env) end |