Class: Oxidized::API::Web
- Inherits:
-
Object
- Object
- Oxidized::API::Web
- Defined in:
- lib/oxidized/web.rb
Instance Attribute Summary collapse
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Instance Method Summary collapse
-
#initialize(nodes, configuration) ⇒ Web
constructor
A new instance of Web.
- #run ⇒ Object
Constructor Details
#initialize(nodes, configuration) ⇒ 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 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/oxidized/web.rb', line 9 def initialize(nodes, configuration) require 'oxidized/web/webapp' if configuration.instance_of? Asetus::ConfigStruct # New configuration syle: extensions.oxidized-web addr = configuration.listen? || '127.0.0.1' port = configuration.port? || 8888 uri = configuration.url_prefix? || '' vhosts = configuration.vhosts? || [] else # Old configuration stlyle: "rest: 127.0.0.1:8888/prefix" listen, uri = configuration.split '/' addr, _, port = listen.rpartition ':' unless port port = addr addr = nil end vhosts = [] end uri = "/#{uri}" @opts = { Host: addr, Port: port } WebApp.set :nodes, nodes WebApp.set :host_authorization, { permitted_hosts: vhosts } @app = Rack::Builder.new do map uri do run WebApp end end end |
Instance Attribute Details
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
7 8 9 |
# File 'lib/oxidized/web.rb', line 7 def thread @thread end |
Instance Method Details
#run ⇒ Object
41 42 43 44 45 46 |
# File 'lib/oxidized/web.rb', line 41 def run @thread = Thread.new do Rack::Handler::Puma.run @app, **@opts exit! end end |