Sha256: f22415ba06f9fd32a1f08a9ba2638ff1a7c566f6666683ae82cc56e689f0db39

Contents?: true

Size: 937 Bytes

Versions: 1

Compression:

Stored size: 937 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)
        begin #TODO: GJ: cache should handle errors gracefully
          env[:restpack] ||= {}

          host = env["SERVER_NAME"]
      
          restpack[:host] = host
       
          channel = @core_cache.get_channel(host)
          domain = channel.get_domain_by_host(host)
          
          env[:restpack][:channel] = channel
          env[:restpack][:application] = domain.application
          env[: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.4 lib/restpack-web/app.rb