Class: Maveric::MongrelHandler

Inherits:
Mongrel::HttpHandler
  • Object
show all
Defined in:
lib/maveric/mongrel.rb

Instance Method Summary collapse

Constructor Details

#initialize(maveric, opts = {}) ⇒ MongrelHandler

Returns a new instance of MongrelHandler.



4
5
6
7
8
9
10
# File 'lib/maveric/mongrel.rb', line 4

def initialize maveric, opts={}
  ::Maveric.type_check :maveric, maveric do |k| k <= ::Maveric end
  ::Maveric.type_check :opts, opts, Hash
  super()
  @request_notify = true
  @maveric = maveric.new opts
end

Instance Method Details

#process(request, response) ⇒ Object

NOTE: Update doc.



14
15
16
17
18
19
20
21
22
# File 'lib/maveric/mongrel.rb', line 14

def process request, response
  Maveric.log.info "Mongrel+#{self.class}#process"
  reply = @maveric.process request.body, request.params
  # output the result
  response.start reply.status do |head,out|
    reply.headers.each {|k,v| head[k] = v }
    out.write reply.body
  end
end

#request_begins(params) ⇒ Object

Prepares by loading session and reflection data into the request params.



25
26
27
28
29
30
31
32
# File 'lib/maveric/mongrel.rb', line 25

def request_begins params
  begin
    Maveric.log.info "Mongrel+#{self.class}#request_begins"
    @maveric.prepare_environment params
  rescue
    Maveric.log.fatal "#{$!.inspect}\n#{$@[0..5]*"\n"}"
  end
end

#request_progess(params, clen, total) ⇒ Object

Does nothing yet. Yet.



35
36
37
38
39
40
41
42
43
# File 'lib/maveric/mongrel.rb', line 35

def request_progess params, clen, total
  begin
    Maveric.log.info "Mongrel+#{self.class}#request_progess"+
      ": #{clen}/#{total}"
    Maveric.log.debug params
  rescue
    Maveric.log.fatal "#{$!.inspect}\n#{$@[0..5]*"\n"}"
  end
end