Class: Weary::Middleware::Timeout
- Inherits:
-
Object
- Object
- Weary::Middleware::Timeout
- Defined in:
- lib/weary/middleware/timeout.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, time = 15) ⇒ Timeout
constructor
A new instance of Timeout.
Constructor Details
#initialize(app, time = 15) ⇒ Timeout
Returns a new instance of Timeout.
7 8 9 10 |
# File 'lib/weary/middleware/timeout.rb', line 7 def initialize(app, time = 15) @app = app @time = time end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/weary/middleware/timeout.rb', line 12 def call(env) begin ::Timeout.timeout(@time) { @app.call(env) } rescue ::Timeout::Error => e [504, {'Content-Type' => "text/plain"}, [e.]] end end |