Sha256: 39dcadf5003fba9d605499c210d318ba5edc09d260daee881a25fd44987f7935

Contents?: true

Size: 856 Bytes

Versions: 16

Compression:

Stored size: 856 Bytes

Contents

require 'eventmachine'
module AgileProxy
  module Servers
    #
    # The 'Request Spec' server
    # This server is responsible for handling or passing through a request, depending
    # on if it has a matching 'Request Specification'
    class RequestSpec
      # Starts the server
      def self.start
        new.start
      end
      def initialize
        @request_handler = AgileProxy::RequestHandler.new
      end
      # Starts the server
      def start
        @signature = EM.start_server('127.0.0.1', AgileProxy.config.proxy_port, ProxyConnection) do |p|
          p.handler = @request_handler
        end
        self
      end
      # The port the server is running on
      # @return [Integer] The port the server is running on
      def port
        Socket.unpack_sockaddr_in(EM.get_sockname(@signature)).first
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
agile-proxy-0.1.22 lib/agile_proxy/servers/request_spec.rb
agile-proxy-0.1.20 lib/agile_proxy/servers/request_spec.rb
agile-proxy-0.1.19 lib/agile_proxy/servers/request_spec.rb
agile-proxy-0.1.18 lib/agile_proxy/servers/request_spec.rb
agile-proxy-0.1.13 lib/agile_proxy/servers/request_spec.rb
agile-proxy-0.1.12 lib/agile_proxy/servers/request_spec.rb
agile-proxy-0.1.11 lib/agile_proxy/servers/request_spec.rb
agile-proxy-0.1.10 lib/agile_proxy/servers/request_spec.rb
agile-proxy-0.1.9 lib/agile_proxy/servers/request_spec.rb
agile-proxy-0.1.8 lib/agile_proxy/servers/request_spec.rb
agile-proxy-0.1.7 lib/agile_proxy/servers/request_spec.rb
agile-proxy-0.1.6 lib/agile_proxy/servers/request_spec.rb
agile-proxy-0.1.5 lib/agile_proxy/servers/request_spec.rb
agile-proxy-0.1.4 lib/agile_proxy/servers/request_spec.rb
agile-proxy-0.1.2 lib/agile_proxy/servers/request_spec.rb
agile-proxy-0.1.0 lib/agile_proxy/servers/request_spec.rb