*/
class Router
{
- const POST = 'POST';
- const GET = 'GET';
+ const DELETE = 'DELETE';
+ const GET = 'GET';
+ const PATCH = 'PATCH';
+ const POST = 'POST';
+ const PUT = 'PUT';
const ALLOWED_METHODS = [
- self::POST,
+ self::DELETE,
self::GET,
+ self::PATCH,
+ self::POST,
+ self::PUT,
];
/** @var RouteCollector */
$this->routeCollector = isset($routeCollector) ?
$routeCollector :
new RouteCollector(new Std(), new GroupCountBased());
+
+ if ($this->baseRoutesFilepath && !file_exists($this->baseRoutesFilepath)) {
+ throw new HTTPException\InternalServerErrorException('Routes file path does\'n exist.');
+ }
}
/**
{
$dispatchData = [];
- if ($this->baseRoutesFilepath && file_exists($this->baseRoutesFilepath)) {
+ if ($this->baseRoutesFilepath) {
$dispatchData = require $this->baseRoutesFilepath;
if (!is_array($dispatchData)) {
throw new HTTPException\InternalServerErrorException('Invalid base routes file');
$lastRoutesFileModifiedTime = $this->cache->get('lastRoutesFileModifiedTime');
$forceRecompute = false;
- if ($this->baseRoutesFilepath && file_exists($this->baseRoutesFilepath)) {
+ if ($this->baseRoutesFilepath) {
$routesFileModifiedTime = filemtime($this->baseRoutesFilepath);
$forceRecompute = $lastRoutesFileModifiedTime != $routesFileModifiedTime;
}