Sha256: 6ffdf5fec05cf18d8f304f594b3571aceaa6e992b0d1b122e3e1dc0f3f07c400

Contents?: true

Size: 1006 Bytes

Versions: 4

Compression:

Stored size: 1006 Bytes

Contents

require 'alephant/broker/version'
require 'alephant/broker/request'
require 'alephant/broker/environment'
require 'alephant/broker'

module Alephant
  module Broker

    def self.handle(env)
      Request::Handler.process env
    end

    def self.config
      @@configuration
    end

    def self.config=(c)
      @@configuration = c
    end

    class Application
      def initialize(c = nil)
        Broker.config = c unless c.nil?
      end

      def call(env)
        send response_for(environment_for(env))
      end

      def environment_for(env)
        Environment.new env
      end

      def response_for(call_environment)
        Broker.handle call_environment
      end

      def send(response)
        [
          response.status,
          {
            "Content-Type" => response.content_type,
            "X-Version"    => response.version.to_s,
            "X-Cached"     => response.cached.to_s
          },
          [ response.content.to_s ]
        ]
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alephant-broker-1.0.5 lib/alephant/broker.rb
alephant-broker-1.0.4 lib/alephant/broker.rb
alephant-broker-1.0.3 lib/alephant/broker.rb
alephant-broker-1.0.2 lib/alephant/broker.rb