Class: Oxidized::API::Web

Inherits:
Object
  • Object
show all
Defined in:
lib/oxidized/web.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nodes, listen) ⇒ Web

Returns a new instance of Web.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/oxidized/web.rb', line 9

def initialize(nodes, listen)
  require 'oxidized/web/webapp'
  listen, uri = listen.split '/'
  addr, _, port = listen.rpartition ':'
  unless port
    port = addr
    addr = nil
  end
  uri = "/#{uri}"
  @opts = {
    Host: addr,
    Port: port
  }
  WebApp.set :nodes, nodes
  @app = Rack::Builder.new do
    map uri do
      run WebApp
    end
  end
end

Instance Attribute Details

#threadObject (readonly)

Returns the value of attribute thread.



7
8
9
# File 'lib/oxidized/web.rb', line 7

def thread
  @thread
end

Instance Method Details

#runObject



30
31
32
33
34
35
# File 'lib/oxidized/web.rb', line 30

def run
  @thread = Thread.new do
    Rack::Handler::Puma.run @app, **@opts
    exit!
  end
end