Class: HTTP::Feature
- Inherits:
-
Object
- Object
- HTTP::Feature
- Defined in:
- lib/http/feature.rb
Overview
Base class for HTTP client features (middleware)
Direct Known Subclasses
HTTP::Features::AutoDeflate, HTTP::Features::AutoInflate, HTTP::Features::Caching, HTTP::Features::DigestAuth, HTTP::Features::Instrumentation, HTTP::Features::Logging, HTTP::Features::NormalizeUri, HTTP::Features::RaiseError
Instance Method Summary collapse
-
#around_request(request) {|HTTP::Request| ... } ⇒ HTTP::Response
Wraps the HTTP exchange for a single request attempt.
-
#on_error(_request, _error) ⇒ nil
Callback for request errors.
-
#on_request(_request) ⇒ nil
Callback invoked before each request attempt.
-
#wrap_request(request) ⇒ HTTP::Request
Wraps an HTTP request.
-
#wrap_response(response) ⇒ HTTP::Response
Wraps an HTTP response.
Instance Method Details
#around_request(request) {|HTTP::Request| ... } ⇒ HTTP::Response
Wraps the HTTP exchange for a single request attempt
Called once per attempt (including retries), wrapping the send and receive cycle. The block performs the I/O and returns the response. Override this to add behavior that must span the entire exchange, such as instrumentation spans or circuit breakers.
62 63 64 |
# File 'lib/http/feature.rb', line 62 def around_request(request) yield request end |
#on_error(_request, _error) ⇒ nil
Callback for request errors
75 |
# File 'lib/http/feature.rb', line 75 def on_error(_request, _error); end |
#on_request(_request) ⇒ nil
Callback invoked before each request attempt
Unlike #wrap_request, which is called once when the request is built, this hook is called before every attempt, including retries. Use it for per-attempt side effects like starting instrumentation spans.
42 |
# File 'lib/http/feature.rb', line 42 def on_request(_request); end |
#wrap_request(request) ⇒ HTTP::Request
Wraps an HTTP request
14 15 16 |
# File 'lib/http/feature.rb', line 14 def wrap_request(request) request end |
#wrap_response(response) ⇒ HTTP::Response
Wraps an HTTP response
26 27 28 |
# File 'lib/http/feature.rb', line 26 def wrap_response(response) response end |