Class: ActionDispatch::PermissionsPolicy::Middleware
- Inherits:
-
Object
- Object
- ActionDispatch::PermissionsPolicy::Middleware
- Defined in:
- lib/action_dispatch/http/permissions_policy.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
33 34 35 |
# File 'lib/action_dispatch/http/permissions_policy.rb', line 33 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File '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 |