Module: Rack::Cargo::RequestExecutor
- Defined in:
- lib/rack/cargo/request_executor.rb
Class Method Summary collapse
Class Method Details
.call(_request, state) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rack/cargo/request_executor.rb', line 7 def call(_request, state) app = state.fetch(:app) request_env = state.fetch(:request_env) status, headers, body = with_timeout(Rack::Cargo.config.timeout) do app.call(request_env) end body.close if body.respond_to?(:close) state[:app_response] = { status: status, headers: headers, body: body } end |
.timeout_response ⇒ Object
30 31 32 |
# File 'lib/rack/cargo/request_executor.rb', line 30 def timeout_response [504, {}, ["{}"]] end |
.with_timeout(seconds, &block) ⇒ Object
24 25 26 27 28 |
# File 'lib/rack/cargo/request_executor.rb', line 24 def with_timeout(seconds, &block) Timeout.timeout(seconds, &block) rescue Timeout::Error timeout_response end |