Class: Namira::Middleware::Network
- Inherits:
-
Object
- Object
- Namira::Middleware::Network
- Defined in:
- lib/namira/middleware/network.rb
Overview
Performs the network request
Instance Method Summary collapse
-
#call(env) ⇒ Object
Called by the middleware runner.
-
#initialize(app) ⇒ Network
constructor
A new instance of Network.
Constructor Details
#initialize(app) ⇒ Network
Returns a new instance of Network.
6 7 8 |
# File 'lib/namira/middleware/network.rb', line 6 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
Called by the middleware runner.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/namira/middleware/network.rb', line 14 def call(env) timeout = env.config[:timeout] || 30.0 http = HTTP.timeout( :per_operation, write: timeout, connect: timeout, read: timeout ) http = http.headers(env.headers) env.response = http.send(env.method, env.uri, body: env.body) @app.call(env) end |