PHP Class Psr7Middlewares\Middleware\BasePath

Inheritance: use trait Psr7Middlewares\Utils\BasePathTrait
Show file Open project: oscarotero/psr7-middlewares Class Usage Examples

Public Methods

Method Description
__construct ( string | null $basePath = null ) Constructor. Set the path prefix.
__invoke ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next ) : Psr\Http\Message\ResponseInterface Execute the middleware.
autodetect ( boolean $autodetect = true ) : self Autodetect the basePath.
getBasePath ( Psr\Http\Message\ServerRequestInterface $request ) : string | null Returns the basePath.
getGenerator ( Psr\Http\Message\ServerRequestInterface $request ) : callable | null Returns a callable to build a full path.

Private Methods

Method Description
detectBasePath ( Psr\Http\Message\ServerRequestInterface $request ) : string Auto-detect the base path from the request environment.

Method Details

__construct() public method

Constructor. Set the path prefix.
public __construct ( string | null $basePath = null )
$basePath string | null

__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

autodetect() public method

Autodetect the basePath.
public autodetect ( boolean $autodetect = true ) : self
$autodetect boolean
return self

getBasePath() public static method

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

getGenerator() public static method

Returns a callable to build a full path.
public static getGenerator ( Psr\Http\Message\ServerRequestInterface $request ) : callable | null
$request Psr\Http\Message\ServerRequestInterface
return callable | null