t/GNUmakefile: cleanup test dependencies
[rainbows.git] / t / app_deferred.ru
bloba70b33b022a2a76980a875d72629d3970d6db542
1 #\-E none
2 # can't use non-compatible middleware that doesn't pass "deferered?" calls
4 # used for testing deferred actions for Merb and possibly other frameworks
5 # ref: http://brainspl.at/articles/2008/04/18/deferred-requests-with-merb-ebb-and-thin
7 class DeferredApp < Struct.new(:app)
8   def deferred?(env)
9     env["PATH_INFO"] == "/deferred"
10   end
12   def call(env)
13     env["rack.multithread"] or raise RuntimeError, "rack.multithread not true"
14     body = "#{Thread.current.inspect}\n"
15     headers = {
16       "Content-Type" => "text/plain",
17       "Content-Length" => body.size.to_s,
18     }
19     [ 200, headers, [ body ] ]
20   end
21 end
23 run DeferredApp.new