Module: Tipi::RackAdapter
- Defined in:
- lib/tipi/rack_adapter.rb
Class Method Summary collapse
- .env(request) ⇒ Object
- .load(path) ⇒ Object
- .respond(request, status_code, headers, body) ⇒ Object
- .run(app) ⇒ Object
Class Method Details
.env(request) ⇒ Object
17 18 19 |
# File 'lib/tipi/rack_adapter.rb', line 17 def env(request) Qeweney.rack_env_from_request(request) end |
.load(path) ⇒ Object
12 13 14 15 |
# File 'lib/tipi/rack_adapter.rb', line 12 def load(path) src = IO.read(path) instance_eval(src, path, 1) end |
.respond(request, status_code, headers, body) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/tipi/rack_adapter.rb', line 21 def respond(request, (status_code, headers, body)) headers[':status'] = status_code.to_s content = if body.respond_to?(:to_path) File.open(body.to_path, 'rb') { |f| f.read } else body.first end request.respond(content, headers) end |
.run(app) ⇒ Object
8 9 10 |
# File 'lib/tipi/rack_adapter.rb', line 8 def run(app) ->(req) { respond(req, app.(env(req))) } end |