Skip to content

Commit

Permalink
test_rig now gives a fully-descriptive response
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip (flip) Kromer committed May 10, 2011
1 parent 606a1a0 commit d5f30b5
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion examples/test_rig.rb
Expand Up @@ -107,7 +107,20 @@ class TestRig < Goliath::API
use Echo # replace status, headers or body if 'echo_status' etc given
use Delay # make response take X seconds if 'delay' param

def on_headers(env, headers)
env['client-headers'] = headers
end

def response(env)
[200, {}, { :result => "normal result" }]
query_params = env.params.collect { |param| param.join(": ") }
query_headers = env['client-headers'].collect { |param| param.join(": ") }

headers = {
"Special" => "Header",
"Params" => query_params.join("|"),
"Path" => env[Goliath::Request::REQUEST_PATH],
"Headers" => query_headers.join("|"),
"Method" => env[Goliath::Request::REQUEST_METHOD]}
[200, headers, headers.dup]
end
end

0 comments on commit d5f30b5

Please sign in to comment.