Merge pull request #31642 from fatkodima/metal-action-duplication

Remove code duplication for `ActionController::Metal.action`
This commit is contained in:
Rafael França 2018-01-24 16:57:34 -05:00 committed by GitHub
commit f03889136a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -230,18 +230,16 @@ def self.middleware
# Returns a Rack endpoint for the given action name.
def self.action(name)
app = lambda { |env|
req = ActionDispatch::Request.new(env)
res = make_response! req
new.dispatch(name, req, res)
}
if middleware_stack.any?
middleware_stack.build(name) do |env|
req = ActionDispatch::Request.new(env)
res = make_response! req
new.dispatch(name, req, res)
end
middleware_stack.build(name, app)
else
lambda { |env|
req = ActionDispatch::Request.new(env)
res = make_response! req
new.dispatch(name, req, res)
}
app
end
end