Sha256: 3442687c381409bfaf00e7a5df9bd52b47f470c4224715546fe619640560efa1

Contents?: true

Size: 733 Bytes

Versions: 4

Compression:

Stored size: 733 Bytes

Contents

require 'json'

module Oxidized
  module API
    class Web
      require 'rack/handler'
      attr_reader :thread
      Rack::Handler::WEBrick = Rack::Handler.get(:puma)
      def initialize nodes, listen
        require 'oxidized/web/webapp'
        listen, uri = listen.split '/'
        addr, _, port = listen.rpartition ':'
        port, addr = addr, nil if not port
        uri = '/' + uri.to_s
        @opts = {
          Host: addr,
          Port: port,
        }
        WebApp.set :nodes, nodes
        @app = Rack::Builder.new do
          map uri do
            run WebApp
          end
        end
      end

      def run
        @thread = Thread.new { Rack::Handler::Puma.run @app, @opts }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
oxidized-web-0.9.3 lib/oxidized/web.rb
oxidized-web-0.9.2 lib/oxidized/web.rb
oxidized-web-0.9.1 lib/oxidized/web.rb
oxidized-web-0.9.0 lib/oxidized/web.rb