Class: WAB::Impl::ExportProxy

Inherits:
WEBrick::HTTPServlet::FileHandler
  • Object
show all
Defined in:
lib/wab/impl/export_proxy.rb

Overview

A handler that provides missing files in an assets directory where the files are the wab and wab UI files.

Instance Method Summary collapse

Constructor Details

#initialize(server, path) ⇒ ExportProxy

Returns a new instance of ExportProxy.



11
12
13
# File 'lib/wab/impl/export_proxy.rb', line 11

def initialize(server, path)
  super
end

Instance Method Details

#do_GET(req, res) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/wab/impl/export_proxy.rb', line 15

def do_GET(req, res)
  super
rescue Exception => e
  path = req.path
  path = '/index.html' if '/' == path
  begin
    mime = nil
    index = path.rindex('.')
    unless index.nil?
      mime = WEBrick::HTTPUtils::DefaultMimeTypes[path[index + 1..-1]]
    end
    mime = 'text/plain' if mime.nil?
    content = WAB.get_export(path)
    res.status = 200
    res['Content-Type'] = mime
    res.body = content
  rescue Exception
    # raise the original error for a normal not found error
    raise e
  end
end