Class: Rack::Handler::Trinidad
- Inherits:
-
Servlet
- Object
- Servlet
- Rack::Handler::Trinidad
- Defined in:
- lib/rack/handler/trinidad.rb
Class Method Summary collapse
- .create_servlet(app) ⇒ Object
- .parse_options(options = {}) ⇒ Object
- .run(app, options = {}) {|server| ... } ⇒ Object
- .valid_options ⇒ Object
Class Method Details
.create_servlet(app) ⇒ Object
49 50 51 52 53 |
# File 'lib/rack/handler/trinidad.rb', line 49 def self.create_servlet(app) context = org.jruby.rack..Context.new('Trinidad') dispatcher = org.jruby.rack..Dispatcher.new(context, self.new(app)) org.jruby.rack..Servlet.new(dispatcher, context) end |
.parse_options(options = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rack/handler/trinidad.rb', line 32 def self.( = {}) # some libs use :Port, :port and :Host, :host, unify this opts = {} .each {|k, v| opts[k.to_s.downcase.to_sym] = v} # this is rack's configuration file but also the trinidad's configuration. # Removing it we allow to load trinidad's default configuration. opts.delete(:config) threads = (opts[:threads] || '1:1').split(':') opts[:port] ||= 3000 opts[:address] ||= opts[:host] || 'localhost' # NOTE: this is currently not supported by embedded Dispatcher and has no effect : opts[:jruby_min_runtimes], opts[:jruby_max_runtimes] = threads[0].to_i, threads[1].to_i opts end |
.run(app, options = {}) {|server| ... } ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rack/handler/trinidad.rb', line 12 def self.run(app, ={}) opts = () servlet = create_servlet(app) opts[:servlet] = {:instance => servlet, :name => 'RackServlet'} ::Trinidad::CommandLineParser.load(opts) server = ::Trinidad::Server.new yield server if block_given? server.start end |
.valid_options ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/rack/handler/trinidad.rb', line 24 def self. { "Host=HOST" => "Hostname to listen on (default: localhost)", "Port=PORT" => "Port to listen on (default: 8080)", "Threads=MIN:MAX" => "min:max threads to use (default 1:1, threadsafe)", } end |