private function router()
    {
        $routes = require $this->config['paths']['routes'];
        $request = \Zend\Diactoros\ServerRequestFactory::fromGlobals();

        $cacheFileName = 'routes.'.filemtime($this->config['paths']['routes']).'.cache';
        $cacheFile = $this->config['paths']['routesCache'].'/'.$cacheFileName;

        if (!file_exists($cacheFile)) {
            array_map('unlink', glob($this->config['paths']['routesCache'].'/*.cache'));
        }

        $dispatcher = \FastRoute\cachedDispatcher(
            function(\FastRoute\RouteCollector $r) use ($routes) {
                foreach ($routes as $route) {
                    $r->addRoute($route['methods'], $route['endpoint'], $route['call']);
                }
            },
            [
                'cacheFile' => $cacheFile,
            ]
        );

        $request = $request->withHeader('lang', $this->config['lang']);
        $request = $request->withHeader('config', json_encode($this->config));

        $routeInfo = $dispatcher->dispatch(
            $request->getMethod(),
            $request->getUri()->getPath()
        );

        $response = new \Zend\Diactoros\Response();

        switch ($routeInfo[0]) {

            case \FastRoute\Dispatcher::METHOD_NOT_ALLOWED:
                $response->getBody()->write('METHOD NOT ALLOWED');
                $response = $response->withStatus(405);
                $this->response = $response;
                break;

            case \FastRoute\Dispatcher::NOT_FOUND:
            case \FastRoute\Dispatcher::FOUND:

                $handler = isset($routeInfo[1]) ? $routeInfo[1] : $this->config['config']['not_found_controller'];
                $vars = isset($routeInfo[2]) ? $routeInfo[2] : [];
                $handler = explode('::', $handler);
                $class = $handler[0];
                $method = $handler[1];

                $response = (new \SideDevOrg\MiniPhpFw\Resolver())->dispatch(
                    $class,
                    $method,
                    $vars,
                    $request,
                    $response,
                    $middlewares = require $this->config['paths']['middlewares']
                );

                if (!isset($routeInfo[1])) {
                    $response = $response->withStatus(404);
                }
                $this->response = $response;
                break;
        }
    }