Sha256: 856947600a7965b2faed7589862a824c38f8e9aeb899cea4af0b8d7317adcfaf

Contents?: true

Size: 839 Bytes

Versions: 1

Compression:

Stored size: 839 Bytes

Contents

require 'lite_cable'
require 'lite_cable/server'
require 'puma/configuration'
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: Rubrowser::Connection
          run proc { |_| [200, { 'Content-Type' => 'text/plain' }, ['OK']] }
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubrowser-2.7.0 lib/rubrowser/server.rb