Module: WAB::Impl::WEBrick::Server
- Defined in:
- lib/wab/impl/webrick/server.rb
Overview
The Server module provides a server start method.
Class Method Summary collapse
-
.start(shell) ⇒ Object
Start the WEBrick server and set the mount points.
Class Method Details
.start(shell) ⇒ Object
Start the WEBrick server and set the mount points.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/wab/impl/webrick/server.rb', line 12 def self.start(shell) mime_types = ::WEBrick::HTTPUtils::DefaultMimeTypes mime_types['es6'] = 'application/javascript' server = ::WEBrick::HTTPServer.new(Port: shell.http_port, DocumentRoot: shell.http_dir, MimeTypes: mime_types) server.logger.level = 5 - shell.logger.level unless shell.logger.nil? shell.mounts.each { |hh| if hh.has_key?(:type) server.mount("#{shell.pre_path}/#{hh[:type]}", WAB::Impl::WEBrick::Handler, shell, shell.create_controller(hh[:handler]), false) elsif hh.has_key?(:path) server.mount(hh[:path], WAB::Impl::WEBrick::Handler, shell, shell.create_controller(hh[:handler]), true) else raise WAB::Error.new("Invalid handle configuration. Missing path or type.") end } server.mount(shell.tql_path, TqlHandler, shell) unless (shell.tql_path.nil? || shell.tql_path.empty?) server.mount('/', ExportProxy, shell.http_dir) if shell.export_proxy trap 'INT' do server.shutdown end server.start end |