mirror of
https://github.com/lostisland/faraday.git
synced 2025-11-18 00:04:09 -05:00
Move #app from Connection to Builder
This commit is contained in:
parent
64892e2e9c
commit
d10c01f111
@ -73,6 +73,17 @@ module Faraday
|
||||
self.class.new(@handlers.dup)
|
||||
end
|
||||
|
||||
def app
|
||||
@app ||= begin
|
||||
lock!
|
||||
to_app(lambda { |env|
|
||||
response = Response.new
|
||||
response.finish(env) unless env.parallel?
|
||||
env.response = response
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
def to_app(inner_app)
|
||||
# last added handler is the deepest and thus closest to the inner app
|
||||
@handlers.reverse.inject(inner_app) { |app, handler| handler.build(app) }
|
||||
|
||||
@ -100,26 +100,7 @@ module Faraday
|
||||
|
||||
extend Forwardable
|
||||
|
||||
def_delegators :builder, :build, :use, :request, :response, :adapter
|
||||
|
||||
# The "rack app" wrapped in middleware. All requests are sent here.
|
||||
#
|
||||
# The builder is responsible for creating the app object. After this,
|
||||
# the builder gets locked to ensure no further modifications are made
|
||||
# to the middleware stack.
|
||||
#
|
||||
# Returns an object that responds to `call` and returns a Response.
|
||||
def app
|
||||
@app ||= begin
|
||||
builder.lock!
|
||||
builder.to_app(lambda { |env|
|
||||
# the inner app that creates and returns the Response object
|
||||
response = Response.new
|
||||
response.finish(env) unless env.parallel?
|
||||
env.response = response
|
||||
})
|
||||
end
|
||||
end
|
||||
def_delegators :builder, :build, :use, :request, :response, :adapter, :app
|
||||
|
||||
# Public: Makes an HTTP request without a body.
|
||||
#
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user