PHP Class Psr7Middlewares\Middleware\Csp

Show file Open project: oscarotero/psr7-middlewares

Public Methods

Method Description
__construct ( array $policies = null ) Set CSPBuilder.
__invoke ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next ) : Psr\Http\Message\ResponseInterface Execute the middleware.
addDirective ( string $directive, mixed $value ) : self Add a directive if it doesn't already exist If it already exists, do nothing.
addSource ( string $directive, string $path ) : self Add a source to our allow whitelist.
supportOldBrowsers ( boolean $support = true ) : self Whether or not support old browsers (e.g. safari).

Method Details

__construct() public method

Set CSPBuilder.
public __construct ( array $policies = null )
$policies array

__invoke() public method

Execute the middleware.
public __invoke ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next ) : Psr\Http\Message\ResponseInterface
$request Psr\Http\Message\ServerRequestInterface
$response Psr\Http\Message\ResponseInterface
$next callable
return Psr\Http\Message\ResponseInterface

addDirective() public method

Add a directive if it doesn't already exist If it already exists, do nothing.
public addDirective ( string $directive, mixed $value ) : self
$directive string
$value mixed
return self

addSource() public method

Add a source to our allow whitelist.
public addSource ( string $directive, string $path ) : self
$directive string
$path string
return self

supportOldBrowsers() public method

Whether or not support old browsers (e.g. safari).
public supportOldBrowsers ( boolean $support = true ) : self
$support boolean
return self