Class: Rack::Conform::Server
- Inherits:
-
Object
- Object
- Rack::Conform::Server
- Defined in:
- lib/rack/conform/server.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #test(env) ⇒ Object
- #test_cookies(env) ⇒ Object
- #test_echo(env) ⇒ Object
- #test_headers(env) ⇒ Object
- #test_status(env) ⇒ Object
Instance Method Details
#call(env) ⇒ Object
11 12 13 |
# File 'lib/rack/conform/server.rb', line 11 def call(env) self.public_send(test_method_for(env), env) end |
#test(env) ⇒ Object
15 16 17 |
# File 'lib/rack/conform/server.rb', line 15 def test(env) [200, {}, ["Hello World"]] end |
#test_cookies(env) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/rack/conform/server.rb', line 28 def (env) = JSON.parse(env['rack.input'].read) Rack::Response.new.tap do |response| .each do |key, value| response.(key, value) end end.to_a end |
#test_echo(env) ⇒ Object
24 25 26 |
# File 'lib/rack/conform/server.rb', line 24 def test_echo(env) [200, {}, env['rack.input']] end |
#test_headers(env) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rack/conform/server.rb', line 38 def test_headers(env) headers = JSON.parse(env['rack.input'].read) Rack::Response.new.tap do |response| headers.each do |key, value| Array(value).each do |value| response.add_header(key, value) end end end.to_a end |
#test_status(env) ⇒ Object
19 20 21 22 |
# File 'lib/rack/conform/server.rb', line 19 def test_status(env) status = env.fetch('HTTP_STATUS', 200) [status.to_i, {}, []] end |