Class: Azure::Core::Http::HttpFilter
- Inherits:
-
Object
- Object
- Azure::Core::Http::HttpFilter
- Defined in:
- lib/azure/core/http/http_filter.rb
Overview
A filter which can modify the HTTP pipeline both before and after requests/responses. Multiple filters can be nested in a “Russian Doll” model to create a compound HTTP pipeline
Direct Known Subclasses
Instance Method Summary collapse
-
#call(request, _next) ⇒ Object
Executes the filter.
-
#initialize(&block) ⇒ HttpFilter
constructor
Initialize a HttpFilter .
Constructor Details
#initialize(&block) ⇒ HttpFilter
Initialize a HttpFilter
&block - An inline block which implements the filter.
The inline block should take parameters |request, _next| where request is a HttpRequest and _next is an object that implements a method .call which returns an HttpResponse. The block passed to the constructor should also return HttpResponse, either as the result of calling _next.call or by customized logic.
33 34 35 |
# File 'lib/azure/core/http/http_filter.rb', line 33 def initialize(&block) @block = block end |
Instance Method Details
#call(request, _next) ⇒ Object
Executes the filter
request - HttpRequest. The request _next - An object that implements .call (no params)
NOTE: _next is a either a subsequent HttpFilter wrapped in a closure, or the HttpRequest object’s call method. Either way, it must have it’s .call method executed within each filter to
complete the pipeline. _next.call should return an HttpResponse
and so should this Filter.
47 48 49 |
# File 'lib/azure/core/http/http_filter.rb', line 47 def call(request, _next) @block ? @block.call(request, _next) : _next.call end |