Class: Rack::Handler::Plum

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/handler/plum.rb

Class Method Summary collapse

Class Method Details

.run(app, options = {}) {|@server| ... } ⇒ Object

Yields:

  • (@server)

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rack/handler/plum.rb', line 5

def self.run(app, options = {})
  opts = default_options.merge(options)

  config = ::Plum::Rack::Config.new(
    listeners: [
      {
        listener: ::Plum::Rack::TLSListener,
        hostname: opts[:Host],
        port: opts[:Port].to_i
      }
    ],
    debug: !!opts[:Debug]
  )

  @server = ::Plum::Rack::Server.new(app, config)
  yield @server if block_given? # TODO
  @server.start
end

.shutdownObject


24
25
26
# File 'lib/rack/handler/plum.rb', line 24

def self.shutdown
  @server.stop if @server
end

.valid_optionsObject


28
29
30
31
32
33
34
# File 'lib/rack/handler/plum.rb', line 28

def self.valid_options
  {
    "Host=HOST"    => "Hostname to listen on (default: #{default_options[:Host]})",
    "Port=PORT"    => "Port to listen on (default: #{default_options[:Port]})",
    "Debug"        => "Turn on debug mode (default: #{default_options[:Debug]})",
  }
end