class ActionDispatch::PermissionsPolicy::Middleware
def call(env)
def call(env) _, headers, _ = response = @app.call(env) return response if policy_present?(headers) request = ActionDispatch::Request.new(env) if policy = request.permissions_policy headers[ActionDispatch::Constants::FEATURE_POLICY] = policy.build(request.controller_instance) end if policy_empty?(policy) headers.delete(ActionDispatch::Constants::FEATURE_POLICY) end response end
def initialize(app)
def initialize(app) @app = app end
def policy_empty?(policy)
def policy_empty?(policy) policy&.directives&.empty? end
def policy_present?(headers)
def policy_present?(headers) headers[ActionDispatch::Constants::FEATURE_POLICY] end