Merge pull request #31642 from fatkodima/metal-action-duplication
Remove code duplication for `ActionController::Metal.action`
This commit is contained in:
commit
f03889136a
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user