Sha256: a7febc321e0fb1d419619fd2f6dd94f195d8b1fb3abb5b68d7f345ae64b9b582

Contents?: true

Size: 554 Bytes

Versions: 1

Compression:

Stored size: 554 Bytes

Contents

require 'rack'
require_relative '../http_api'

module Kamerling
  module Server
    class HTTP
      attr_reader :addr

      def initialize(addr:)
        @addr = addr
      end

      def join
        thread.join
      end

      def start
        @thread = Thread.new do
          Rack::Handler::WEBrick.run HTTPAPI, Host: addr.host, Port: addr.port
        end
        loop { break if addr.connectable? }
        self
      end

      def stop
        thread.exit.join
      end

      attr_reader :thread
      private     :thread
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kamerling-0.0.3 lib/kamerling/server/http.rb