SilverStripe\ControllerPolicy\Policies\CustomHeaderPolicy
This policy can be used to write or delete arbitrary headers. Set the header to empty string ("") to suppress that header.
Configuration:
SilverStripe\Core\Injector\Injector:
GeneralPolicy:
class: YourVendor\YourModule\CustomHeaderPolicy
properties:
headers:
Cache-Control: "public, max-age=600, no-transform"
Custom-Header: "Hello"
Vary: ""
HomePageController:
dependencies:
Policies:
- '%$GeneralPolicy'
extensions:
- SilverStripe\ControllerPolicy\ControllerPolicyApplicator
Synopsis
class CustomHeaderPolicy
implements
ControllerPolicy
{
- // members
- protected array $headers = ;
- // methods
- public $this setHeaders()
- public array getHeaders()
- public $this addHeader()
- public void applyToResponse()
Hierarchy
Members
protected
- $headers — array
Methods
public
- addHeader() — Add a specific header
- applyToResponse()
- getHeaders() — Get the list of headers to apply to the response
- setHeaders() — Set the full array of headers to apply to the response