protected function _route($request)
    {
        $path = $request['path'];
        $httpMethod = $request['method'];
        $host = $request['host'];
        $scheme = $request['scheme'];

        $allowedSchemes = array_unique([$scheme => $scheme, '*' => '*']);
        $allowedMethods = array_unique([$httpMethod => $httpMethod, '*' => '*']);

        if ($httpMethod === 'HEAD') {
            $allowedMethods += ['GET' => 'GET'];
        }

        foreach ($this->_routes as $scheme => $hostBasedRoutes) {
            if (!isset($allowedSchemes[$scheme])) {
                continue;
            }
            foreach ($hostBasedRoutes as $routeHost => $methodBasedRoutes) {
                foreach ($methodBasedRoutes as $method => $routes) {
                    if (!isset($allowedMethods[$method]) && $httpMethod !== '*') {
                        continue;
                    }
                    foreach ($routes as $route) {
                        if (!$route->match($request, $variables, $hostVariables)) {
                            if ($hostVariables === null) {
                                continue 3;
                            }
                            continue;
                        }
                        return $route;
                    }
                }
            }
        }
    }
protected function _route($request)
    {
        $path = $request['path'];
        $httpMethod = $request['method'];
        $host = $request['host'];
        $scheme = $request['scheme'];

        $allowedSchemes = array_unique([$scheme => $scheme, '*' => '*']);
        $allowedMethods = array_unique([$httpMethod => $httpMethod, '*' => '*']);

        if ($httpMethod === 'HEAD') {
            $allowedMethods += ['GET' => 'GET'];
        }

        foreach ($this->_routes as $scheme => $hostBasedRoutes) {
            if (!isset($allowedSchemes[$scheme])) {
                continue;
            }
            foreach ($hostBasedRoutes as $routeHost => $methodBasedRoutes) {
                foreach ($methodBasedRoutes as $method => $routes) {
                    if (!isset($allowedMethods[$method]) && $httpMethod !== '*') {
                        continue;
                    }
                    foreach ($routes as $route) {
                        if (!$route->match($request, $variables, $hostVariables)) {
                            if ($hostVariables === null) {
                                continue 3;
                            }
                            continue;
                        }
                        return $route;
                    }
                }
            }
        }
    }
protected function _route ( $ request ) { $ path = $ request [ 'path' ] ; $ httpMethod = $ request [ 'method' ] ; $ host = $ request [ 'host' ] ; $ scheme = $ request [ 'scheme' ] ; $ allowedSchemes = array_unique ( [ $ scheme => $ scheme , '*' => '*' ] ) ; $ allowedMethods = array_unique ( [ $ httpMethod => $ httpMethod , '*' => '*' ] ) ; if ( $ httpMethod === 'HEAD' ) { $ allowedMethods += [ 'GET' => 'GET' ] ; } foreach ( $ this -> _routes as $ scheme => $ hostBasedRoutes ) { if ( ! isset ( $ allowedSchemes [ $ scheme ] ) ) { continue ; } foreach ( $ hostBasedRoutes as $ routeHost => $ methodBasedRoutes ) { foreach ( $ methodBasedRoutes as $ method => $ routes ) { if ( ! isset ( $ allowedMethods [ $ method ] ) && $ httpMethod !== '*' ) { continue ; } foreach ( $ routes as $ route ) { if ( ! $ route -> match ( $ request , $ variables , $ hostVariables ) ) { if ( $ hostVariables === null ) { continue 3 ; } continue ; } return $ route ; } } } } }
Routes a request.

@param array $request The request to route.
Routes a request .