Class Maveric::WEBrickServlet
In: maveric/webrick.rb
Parent: WEBrick::HTTPServlet::AbstractServlet

Adaptation of CampingHandler, quick works.

Methods

new   service  

Public Class methods

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.

[Source]

    # File maveric/webrick.rb, line 10
10:   def initialize server, maveric, *opts
11:     ::Maveric.type_check :maveric, maveric do |k| k <= ::Maveric end
12:     @maveric = maveric.new *@options
13:     super server, *opts
14:   end

Public Instance methods

We don‘t need no stinkin’ do_* methods.

[Source]

    # File maveric/webrick.rb, line 17
17:   def service req, res
18:     begin
19:       ::Maveric.log.warn req.inspect
20:       req_body = StringIO.new(req.body || '')
21:       env = req.meta_vars
22:       env['REQUEST_URI'] = req.unparsed_uri
23:       result = @maveric.dispatch req_body, env, req
24:       result.headers.each do |k, v|
25:         if k =~ /^X-SENDFILE$/i then @local_path = v
26:         else [*v].each {|x| res[k] = x } end
27:       end
28:       res.status, h, res.body = *result
29:     rescue ::Maveric::ServerError => error
30:       Maveric.log.fatal "WEBrick done got f'd up: #{error.inspect}"
31:     end
32:   end

[Validate]