Sha256: f1f64b09460c42cce14520a05d65f3155d7934a1ea65d429e7316b1787a4028c

Contents?: true

Size: 815 Bytes

Versions: 1

Compression:

Stored size: 815 Bytes

Contents

require 'lite_cable'
require 'lite_cable/server'
require 'puma'
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

1 entries across 1 versions & 1 rubygems

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