Class: ActionDispatch::FeaturePolicy::Middleware
- Defined in:
- actionpack/lib/action_dispatch/http/feature_policy.rb
Constant Summary collapse
- CONTENT_TYPE =
"Content-Type"
- POLICY =
"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.
11 12 13 |
# File 'actionpack/lib/action_dispatch/http/feature_policy.rb', line 11 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'actionpack/lib/action_dispatch/http/feature_policy.rb', line 15 def call(env) request = ActionDispatch::Request.new(env) _, headers, _ = response = @app.call(env) return response unless html_response?(headers) return response if policy_present?(headers) if policy = request.feature_policy headers[POLICY] = policy.build(request.controller_instance) end if policy_empty?(policy) headers.delete(POLICY) end response end |