Class: BatchApi::InternalMiddleware::ResponseFilter
- Inherits:
-
Object
- Object
- BatchApi::InternalMiddleware::ResponseFilter
- Defined in:
- lib/batch_api/internal_middleware/response_filter.rb
Overview
Public: a batch middleware which surpresses the response from a call. If you know you don’t need a response (for instance, for a POST or PUT), you can add silent: true (or any truthy value, like 1) to your operation to surpress all output for successful requests. Failed requests (status != 2xx) will still return information.
Instance Method Summary collapse
-
#call(env) ⇒ Object
Public: execute the call.
-
#initialize(app) ⇒ ResponseFilter
constructor
Public: init the middleware.
Constructor Details
#initialize(app) ⇒ ResponseFilter
Public: init the middleware.
10 11 12 |
# File 'lib/batch_api/internal_middleware/response_filter.rb', line 10 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/batch_api/internal_middleware/response_filter.rb', line 16 def call(env) @app.call(env).tap do |result| if env[:op].["silent"] && (200...299).include?(result.status) # we have success and a request for silence # so remove all the content before proceeding result.status = result.body = result.headers = nil end end end |