Class: Faraday::Middleware
- Inherits:
-
Object
- Object
- Faraday::Middleware
- Extended by:
- DependencyLoader, MiddlewareRegistry
- Defined in:
- lib/faraday/middleware.rb
Overview
Middleware is the basic base class of any Faraday middleware.
Direct Known Subclasses
Request::Authorization, Request::Instrumentation, Request::Retry, Request::UrlEncoded, Response::Middleware
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Attributes included from DependencyLoader
Instance Method Summary collapse
- #call(env) ⇒ Object
- #close ⇒ Object
-
#initialize(app = nil, options = {}) ⇒ Middleware
constructor
A new instance of Middleware.
Methods included from MiddlewareRegistry
fetch_middleware, load_middleware, lookup_middleware, middleware_mutex, register_middleware, unregister_middleware
Methods included from DependencyLoader
dependency, inherited, loaded?, new
Constructor Details
#initialize(app = nil, options = {}) ⇒ Middleware
Returns a new instance of Middleware.
11 12 13 14 |
# File 'lib/faraday/middleware.rb', line 11 def initialize(app = nil, = {}) @app = app @options = end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
9 10 11 |
# File 'lib/faraday/middleware.rb', line 9 def app @app end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/faraday/middleware.rb', line 9 def @options end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/faraday/middleware.rb', line 16 def call(env) on_request(env) if respond_to?(:on_request) app.call(env).on_complete do |environment| on_complete(environment) if respond_to?(:on_complete) end end |
#close ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/faraday/middleware.rb', line 23 def close if app.respond_to?(:close) app.close else warn "#{app} does not implement \#close!" end end |