Sha256: c1588d5d624af3ba7e370efe6a742f5a064519b3bbabec0f8fc690d76019f808

Contents?: true

Size: 853 Bytes

Versions: 3

Compression:

Stored size: 853 Bytes

Contents

require 'lite_cable'
require 'lite_cable/server'
require 'puma/configuration'
require 'puma/launcher'
require 'rubrowser/connection'

module Rubrowser
  class Server
    def initialize(port: 8080)
      @port = port
    end

    def run
      launcher.run
    end

    private

    attr_reader :port

    def launcher
      @launcher ||= Puma::Launcher.new(conf)
    end

    def conf
      @conf ||= Puma::Configuration.new do |user_config|
        user_config.threads(1, 1)
        user_config.workers 1
        user_config.port port
        user_config.app(rack_app)
      end
    end

    def rack_app
      @app ||= Rack::Builder.new do
        map '/' do
          use LiteCable::Server::Middleware, connection_class: Connection
          run(proc { |_| [200, { 'Content-Type' => 'text/plain' }, ['OK']] })
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubrowser-2.9.1 lib/rubrowser/server.rb
rubrowser-2.9.0 lib/rubrowser/server.rb
rubrowser-2.8.0 lib/rubrowser/server.rb