forked from webmachine/webmachine-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebugger.rb
More file actions
39 lines (32 loc) · 746 Bytes
/
debugger.rb
File metadata and controls
39 lines (32 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require 'webmachine'
require 'webmachine/trace'
class MyTracedResource < Webmachine::Resource
def trace?; true; end
def resource_exists?
case request.query['e']
when 'true'
true
when 'fail'
raise "BOOM"
else
false
end
end
def to_html
"<html>You found me.</html>"
end
end
class MyTracer
def call(name, payload)
puts "MyTracer #{name} #{payload.inspect}"
end
end
# Webmachine::Trace.trace_store = :pstore, "./trace"
# Webmachine::Trace.trace_listener = [Webmachine::Trace::Listener.new, MyTracer.new]
TraceExample = Webmachine::Application.new do |app|
app.routes do
add ['trace', :*], Webmachine::Trace::TraceResource
add [], MyTracedResource
end
end
TraceExample.run