require 'webrick'

class MyServer
  
  def initialize(params)
    @server = WEBrick::HTTPServer.new(params)
  end
  
  def start()
    trap("INT"){ @server.shutdown }
    @server.start
  end

  def publish(path,proc)
    prochandler = WEBrick::HTTPServlet::ProcHandler.new(proc)
    @server.mount(path,prochandler)
  end

  def publish_file(path,fn)
    filehandler = WEBrick::HTTPServlet::FileHandler.new(@server,fn)
    @server.mount(path,filehandler)
  end
  
DOCTYPE = %{<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
	  "http://www.w3.org/TR/html4/loose.dtd">}

META = %{<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-2">}
end

#webrick bug? elkerulesere
class WEBrick::HTTPServlet::FileHandler
  def get_instance(server, *options)
    self
  end
end

