123456789_123456789_123456789_123456789_123456789_

Class: ActionDispatch::PermissionsPolicy::Middleware

Relationships & Source Files
Inherits: Object
Defined in: actionpack/lib/action_dispatch/http/permissions_policy.rb

Constant Summary

Class Method Summary

Instance Method Summary

Constructor Details

.new(app) ⇒ Middleware

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/permissions_policy.rb', line 16

def initialize(app)
  @app = app
end

Instance Method Details

#call(env)

[ GitHub ]

  
# File 'actionpack/lib/action_dispatch/http/permissions_policy.rb', line 20

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.permissions_policy
    headers[POLICY] = policy.build(request.controller_instance)
  end

  if policy_empty?(policy)
    headers.delete(POLICY)
  end

  response
end