Sha256: d42bfbf7ebe2c9417d20d8d97a8d5f4b602ddd1aa41e588a2d1885d1a964c92e

Contents?: true

Size: 943 Bytes

Versions: 1

Compression:

Stored size: 943 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"]
      
          env[: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.5 lib/restpack-web/app.rb