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
# File 'lib/oxidized/web.rb', line 9

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

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



27
28
29
30
31
32
# File 'lib/oxidized/web.rb', line 27

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