Class: ActionDispatch::PermissionsPolicy::Middleware
Relationships & Source Files | |
Inherits: | Object |
Defined in: | actionpack/lib/action_dispatch/http/permissions_policy.rb |
Class Method Summary
- .new(app) ⇒ Middleware constructor
Instance Method Summary
Constructor Details
.new(app) ⇒ Middleware
# File 'actionpack/lib/action_dispatch/http/permissions_policy.rb', line 33
def initialize(app) @app = app end
Instance Method Details
#call(env)
[ GitHub ]# File 'actionpack/lib/action_dispatch/http/permissions_policy.rb', line 37
def call(env) _, headers, _ = response = @app.call(env) return response if policy_present?(headers) request = ActionDispatch::Request.new(env) if policy = request. headers[ActionDispatch::Constants::FEATURE_POLICY] = policy.build(request.controller_instance) end if policy_empty?(policy) headers.delete(ActionDispatch::Constants::FEATURE_POLICY) end response end
#policy_empty?(policy) ⇒ Boolean
(private)
# File 'actionpack/lib/action_dispatch/http/permissions_policy.rb', line 60
def policy_empty?(policy) policy&.directives&.empty? end
#policy_present?(headers) ⇒ Boolean
(private)
# File 'actionpack/lib/action_dispatch/http/permissions_policy.rb', line 56
def policy_present?(headers) headers[ActionDispatch::Constants::FEATURE_POLICY] end