Class: Veewee::Provider::Core::Helper::Servlet::FileServlet
- Inherits:
-
WEBrick::HTTPServlet::AbstractServlet
- Object
- WEBrick::HTTPServlet::AbstractServlet
- Veewee::Provider::Core::Helper::Servlet::FileServlet
- Defined in:
- lib/veewee/provider/core/helper/web.rb
Instance Attribute Summary collapse
-
#threaded ⇒ Object
readonly
Returns the value of attribute threaded.
-
#ui ⇒ Object
readonly
Returns the value of attribute ui.
Instance Method Summary collapse
- #do_GET(request, response) ⇒ Object
-
#initialize(server, localfile, ui, threaded) ⇒ FileServlet
constructor
A new instance of FileServlet.
Constructor Details
#initialize(server, localfile, ui, threaded) ⇒ FileServlet
Returns a new instance of FileServlet.
14 15 16 17 18 19 20 |
# File 'lib/veewee/provider/core/helper/web.rb', line 14 def initialize(server,localfile,ui,threaded) super(server) @server=server @localfile=localfile @ui=ui @threaded=threaded end |
Instance Attribute Details
#threaded ⇒ Object (readonly)
Returns the value of attribute threaded.
12 13 14 |
# File 'lib/veewee/provider/core/helper/web.rb', line 12 def threaded @threaded end |
#ui ⇒ Object (readonly)
Returns the value of attribute ui.
12 13 14 |
# File 'lib/veewee/provider/core/helper/web.rb', line 12 def ui @ui end |
Instance Method Details
#do_GET(request, response) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/veewee/provider/core/helper/web.rb', line 22 def do_GET(request,response) response['Content-Type']='text/plain' response.status = 200 content = File.open(@localfile, "r").read response.body = case File.extname(@localfile) when ".erb" ui.info "Rendering and serving file #{@localfile}" ERB.new(content).result(binding) else ui.info "Serving file #{@localfile}" content end if not @threaded ui.info "Shutting down for #{@localfile}" @server.shutdown end end |