Class: Server

Inherits:
WEBrick::HTTPServer
  • Object
show all
Defined in:
lib/server.rb

Defined Under Namespace

Classes: NonCachingFileHandler

Instance Method Summary collapse

Constructor Details

#initialize(path, port) ⇒ Server

Returns a new instance of Server.



19
20
21
22
23
24
25
26
27
28
# File 'lib/server.rb', line 19

def initialize(path, port)
  @port = port
  @path = path
  mime_types = WEBrick::HTTPUtils::DefaultMimeTypes
  mime_types.store 'js', 'application/javascript'
  super(
    :Port => @port,
    :MimeTypes => mime_types
  )
end

Instance Method Details

#startObject



30
31
32
33
34
35
36
37
38
# File 'lib/server.rb', line 30

def start
  mount("/", NonCachingFileHandler, @path)
  t = Thread.new {
    super
  }

  trap("INT") { shutdown }
  t.join()
end