PHP Class Psr7Middlewares\Middleware\FormatNegotiator

Inheritance: use trait Psr7Middlewares\Utils\NegotiateTrait, use trait Psr7Middlewares\Utils\AttributeTrait
ファイルを表示 Open project: oscarotero/psr7-middlewares Class Usage Examples

Public Methods

Method Description
__invoke ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next ) : Psr\Http\Message\ResponseInterface Execute the middleware.
addFormat ( string $format, array $mimeTypes, array $extensions = null ) : self Add a new format.
defaultFormat ( string $format ) : self Set the default format.
getFormat ( Psr\Http\Message\ServerRequestInterface $request ) : string | null Returns the format.

Private Methods

Method Description
getFromExtension ( Psr\Http\Message\ServerRequestInterface $request ) : null | string Returns the format using the file extension.
getFromHeader ( Psr\Http\Message\ServerRequestInterface $request ) : null | string Returns the format using the Accept header.

Method Details

__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

addFormat() public method

Add a new format.
public addFormat ( string $format, array $mimeTypes, array $extensions = null ) : self
$format string
$mimeTypes array
$extensions array
return self

defaultFormat() public method

Set the default format.
public defaultFormat ( string $format ) : self
$format string
return self

getFormat() public static method

Returns the format.
public static getFormat ( Psr\Http\Message\ServerRequestInterface $request ) : string | null
$request Psr\Http\Message\ServerRequestInterface
return string | null