Class: ActionDispatch::PermissionsPolicy::Middleware
- Inherits:
-
Object
- Object
- ActionDispatch::PermissionsPolicy::Middleware
- Defined in:
- lib/action_dispatch/http/permissions_policy.rb
Constant Summary collapse
- CONTENT_TYPE =
"Content-Type"
- POLICY =
The Feature-Policy header has been renamed to Permissions-Policy. The Permissions-Policy requires a different implementation and isn’t yet supported by all browsers. To avoid having to rename this middleware in the future we use the new name for the middleware but keep the old header name and implementation for now.
"Feature-Policy"
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.
32 33 34 |
# File 'lib/action_dispatch/http/permissions_policy.rb', line 32 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/action_dispatch/http/permissions_policy.rb', line 36 def call(env) request = ActionDispatch::Request.new(env) _, headers, _ = response = @app.call(env) return response if policy_present?(headers) if policy = request. headers[POLICY] = policy.build(request.controller_instance) end if policy_empty?(policy) headers.delete(POLICY) end response end |