Class: Maveric::WEBrickServlet
- Inherits:
-
WEBrick::HTTPServlet::AbstractServlet
- Object
- WEBrick::HTTPServlet::AbstractServlet
- Maveric::WEBrickServlet
- Defined in:
- lib/maveric/webrick.rb
Overview
Adaptation of CampingHandler, quick works.
Instance Method Summary collapse
-
#initialize(server, maveric, *opts) ⇒ WEBrickServlet
constructor
As a WEBrick servlet, but pass all but the first option to the Maveric on initialization.
-
#service(req, res) ⇒ Object
We don’t need no stinkin’ do_* methods.
Constructor Details
#initialize(server, maveric, *opts) ⇒ WEBrickServlet
As a WEBrick servlet, but pass all but the first option to the Maveric on initialization. The Maveric (not an instance) is expected as the first option.
10 11 12 13 14 |
# File 'lib/maveric/webrick.rb', line 10 def initialize server, maveric, *opts ::Maveric.type_check :maveric, maveric do |k| k <= ::Maveric end @maveric = maveric.new *@options super server, *opts end |
Instance Method Details
#service(req, res) ⇒ Object
We don’t need no stinkin’ do_* methods.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/maveric/webrick.rb', line 17 def service req, res begin ::Maveric.log.warn req.inspect req_body = StringIO.new(req.body || '') env = req. env['REQUEST_URI'] = req.unparsed_uri result = @maveric.dispatch req_body, env, req result.headers.each do |k, v| if k =~ /^X-SENDFILE$/i then @local_path = v else [*v].each {|x| res[k] = x } end end res.status, h, res.body = *result rescue ::Maveric::ServerError => error Maveric.log.fatal "WEBrick done got f'd up: #{error.inspect}" end end |