Class: Codebot::WebServer
- Inherits:
-
ThreadController
- Object
- ThreadController
- Codebot::WebServer
- Extended by:
- Sanitizers
- Defined in:
- lib/codebot/web_server.rb
Overview
This class manages a WebListener that runs in a separate thread.
Class Method Summary collapse
-
.configuration ⇒ Proc
Creates a
Proc
for configuring this web server.
Instance Method Summary collapse
-
#initialize(core) ⇒ WebServer
constructor
Creates a new web server.
-
#run ⇒ Object
Starts this web server.
Methods included from Sanitizers
valid!, valid_boolean, valid_channel_key, valid_channel_name, valid_endpoint, valid_host, valid_identifier, valid_network, valid_port, valid_secret, valid_string
Methods inherited from ThreadController
#join, #running?, #start, #start!, #stop, #stop!
Constructor Details
#initialize(core) ⇒ WebServer
Creates a new web server.
17 18 19 |
# File 'lib/codebot/web_server.rb', line 17 def initialize(core) @core = core end |
Class Method Details
.configuration ⇒ Proc
Creates a Proc
for configuring this web server.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/codebot/web_server.rb', line 29 def self.configuration server = self proc do disable :traps set :bind, ENV['CODEBOT_BIND'] unless ENV['CODEBOT_BIND'].to_s.empty? port = ENV['CODEBOT_PORT'] if port.is_a?(String) && !port.empty? set :port, (server.valid! port, server.valid_port(port), nil, invalid_error: 'invalid port %s') end end end |
Instance Method Details
#run ⇒ Object
Starts this web server.
22 23 24 |
# File 'lib/codebot/web_server.rb', line 22 def run(*) create_server.run! end |