Sha256: 6e666d8f2db9305c031b356e5c85ec087ac1483f41073193e1aac48340e55355

Contents?: true

Size: 927 Bytes

Versions: 1

Compression:

Stored size: 927 Bytes

Contents

require 'restpack-core-client'

module RestPack
  module Web
    class App
      def initialize(app, settings)
        p "RestPack::Web::App.initialize"
        @app = app
        @settings = settings
        
        @core_cache = RestPack::Core::Client::Cache.create(@settings[:core_domain], @settings[:password])
      end

      def call(env)      
        restpack = env[:restpack] ||= {}
        host = env["SERVER_NAME"]
      
        restpack[:host] = host
        begin #TODO: GJ: cache should handle errors gracefully
          channel = @core_cache.get_channel(host)
          domain = channel.get_domain_by_identifier(host)
          
          restpack[:channel] = channel
          restpack[:application] = domain.application
          restpack[:domain] = domain
        rescue Exception => e
          p e.message  
          p e.backtrace.inspect
        end

        @app.call(env)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
restpack-web-0.1.2 lib/restpack-web/app.rb