42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/lennarb/plugins/hooks.rb', line 42
def call(env)
catch(:halt) do
req = Lennarb::Request.new(env)
res = Lennarb::Response.new
path = env[Rack::PATH_INFO]
execute_hooks(self.class.instance_variable_get(:@_before_hooks), '*', req, res)
execute_matching_hooks(self.class.instance_variable_get(:@_before_hooks), path, req, res)
status, , body = super
res.status = status
.each { |k, v| res[k] = v }
body.each { |chunk| res.write(chunk) }
execute_matching_hooks(self.class.instance_variable_get(:@_after_hooks), path, req, res)
execute_hooks(self.class.instance_variable_get(:@_after_hooks), '*', req, res)
res.finish
end
rescue StandardError => e
handle_error(e)
end
|