The DefaultRouteNotFound event handler will generate a
route not found error message.

@access public
@param \Zepi\Turbo\Framework $framework
@param \Zepi\Turbo\Request\RequestAbstract $request
@param \Zepi\Turbo\Response\Response $response
322578
public function execute(Framework $framework, RequestAbstract $request, Response $response)
    {
        $response->setOutputPart('404', 'The requested route is not available. We can\'t execute the request. Route: "' . $request->getRoute() . '"');
    }
24805
protected function injectToolbar(Response $response, Request $request)
    {
        if (function_exists('mb_stripos')) {
            $posrFunction = 'mb_strripos';
            $substrFunction = 'mb_substr';
        } else {
            $posrFunction = 'strripos';
            $substrFunction = 'substr';
        }

        $content = $response->getContent();
        $pos = $posrFunction($content, '</body>');

        $page = $request->get('_content', false);

        $page_id = null;
        if ($page instanceof \Networking\InitCmsBundle\Model\PageSnapshot) {
            $page_id = $page->getPage()->getId();
        } elseif ($page instanceof \Networking\InitCmsBundle\Model\Page) {
            $page_id = $page->getId();
        }

        if (false !== $pos) {
            $toolbar = "\n".str_replace("\n", '', $this->twig->render(
                '@NetworkingInitCms/Admin/toolbar_js.html.twig',
                [
                    'position' => $this->position,
                    'page_id' => $page_id,
                ]
            ))."\n";
            $content = $substrFunction($content, 0, $pos).$toolbar.$substrFunction($content, $pos);
            $response->setContent($content);
        }
    }
32518
protected function _processRoute(Context $c, $handler, &$response)
  {
    if($handler === null)
    {
      throw new \RuntimeException(ConditionHandler::ERROR_NO_HANDLER, 500);
    }
    throw new \RuntimeException(self::ERROR_NO_ROUTE, 404);
  }
1042008
protected function  handleFoundRoute($route, Request $request)
    {
        $this->currentRoute = $route;
        $request->attributes->add($route[2]);

        if (isset($route[1]['middleware']) && !empty($route[1]['middleware'])) {
            $middleware = $route[1]['middleware'];
            $middleware = is_string($middleware) ? explode('|', $middleware) : (array) $middleware;
            $middleware = array_map(function ($m) { return $this->middlewareNamespace .'\\'. $m; }, $middleware);

            $response = (new Pipeline())->send($request)->through($middleware)
                ->then(function () use ($route, $request) {
                    return $this->callAction($route, $request);
                });
        }
        else {
            $response = $this->callAction($route, $request);
        }

        if (!$response instanceof Response) {
            $response = new Response($response);
        }

        return $response;
    }
854151
public function execute(Framework $framework, RequestAbstract $request, Response $response, $value = null)
    {
        $accessLevels = $value;
        $dataRequest = new DataRequest(1, 0, 'name', 'ASC');
        
        $groups = $this->groupManager->find($dataRequest);
        
        if ($groups === false) {
            return $accessLevels;
        }
        
        foreach ($groups as $group) {
            $accessLevels[] = new GroupAccessLevel(
                '\\Group\\' . $group->getUuid(),
                $this->translationManager->translate('Group', '\\Zepi\\Web\\AccessControl') . ' ' . $group->getName(),
                $this->translationManager->translate('Inherits all permissions from this group.', '\\Zepi\\Web\\AccessControl'),
                '\\Group'
            );
        }
        
        return $accessLevels;
    }
724432
protected function notFound()
    {
        // Set the default not found response
        $this->response->setContent('File not found');
        $this->response->headers->set('content-type', 'text/html');
        $this->response->setStatusCode(Response::HTTP_NOT_FOUND);

        // Execute the user defined notFound callback
        if (is_callable($this->notFound)) {
            $this->response = call_user_func($this->notFound, $this->response);
        }
    }
590793
public function onRequest(Request $request, Response $response)
    {
        // Initialize Request and Response and set to RequestContent
        $psr7Request = \Swoft\Http\Message\Server\Request::loadFromSwooleRequest($request);
        $psr7Response = new \Swoft\Http\Message\Server\Response($response);

        /** @var \Swoft\Http\Server\ServerDispatcher $dispatcher */
        $dispatcher = App::getBean('serverDispatcher');
        $dispatcher->dispatch($psr7Request, $psr7Response);
    }
811458
protected function notFound(ServerRequestInterface $request, ResponseInterface $response)
    {
        $notFound = $response
            ->withProtocolVersion($request->getProtocolVersion())
            ->withStatus(404);
        
        $notFound->getBody()->write('Not Found');

        return $notFound;
    }
804907
protected function dispatchProcess(Request $request, Response $response)
    {
        if ($request->getController() === null || $request->getAction() === null) {
            throw new ArchException('Controller or action not defined. Router problem?');
        }
        $actionMethod = $request->getAction() . 'Action';
        ob_start();
        $this->dispatched = true;
        $controllerName = $request->getController();
        if (!$controllerName) {
            throw new ArchException('Controller is undefined');
        }
        $controller = Container::getController($controllerName);
        if (!($controller instanceof \Osf\Controller\Action)) {
            throw new ArchException('Your controller class for application ' . $request->getController() . ' must extends \Osf\Controller\Action');
        }
        if (!method_exists($controller, $actionMethod)) {
            throw new HttpException('Action ' . $actionMethod . '() not found in controller class of application ' . $request->getController(), 404);
        }
        if ($this->dispatched) {
            $controller->preDispatch();
            self::debug('Call ' . $controllerName . '::' . $actionMethod . '()');
            $viewParams = $controller->$actionMethod();
            $controller->postDispatch();
            $content = ob_get_clean();
            $content && $response->appendBody($content);
            if ($viewParams === null) {
                $viewParams = [];
            } elseif (!is_array($viewParams)) {
                throw new ArchException('Action must return an array or null');
            }
        } else {
            self::debug('No call of ' . $controllerName . '::' . $actionMethod . '(), not dispatched');
            ob_clean();
        }
        if ($this->dispatched && $this->renderView) {
            $response->appendBody(Container::getView()->register($viewParams)->render());
        }

        return $this;
    }
654800
public function execute(Framework $framework, WebRequest $request, Response $response)
    {
        // Prepare the page
        $additionalTitle = $this->translate('Delete group', '\\Zepi\\Web\\AccessControl');
        $title = $this->translate('Group management', '\\Zepi\\Web\\AccessControl');
        $this->activateMenuEntry('group-administration');
        $this->setTitle($title, $additionalTitle);
        
        // Get the user
        $uuid = $request->getRouteParam('uuid');
        
        // If the UUID does not exists redirect to the overview page
        if (!is_string($uuid) || !$this->groupManager->hasGroupForUuid($uuid)) {
            $response->redirectTo($request->getFullRoute('/administration/groups/'));
            return;
        }
        
        $group = $this->groupManager->getGroupForUuid($uuid);
        
        // If $result isn't true, display the edit user form
        if ($request->getRouteParam('confirmation') === 'confirmed') {
            $this->groupManager->delete($group);
            
            $response->setOutput($this->render('\\Zepi\\Web\\AccessControl\\Templates\\Administration\\DeleteGroupFinished', array(
                'group' => $group
            )));
        } else {
            // Display the delete user confirmation
            $response->setOutput($this->render('\\Zepi\\Web\\AccessControl\\Templates\\Administration\\DeleteGroup', array(
                'group' => $group
            )));
        }
    }
1049695
public function process(Request $request, Handler $handler): Response
    {
        $method = $request->getMethod();
        $uri = $request->getUri()->getPath() ?: '/';

        $routeInfo = $this->getDispatcher()->dispatch($method, $uri);

        switch ($routeInfo[0]) {
            case Dispatcher::NOT_FOUND:
                throw new RouteNotFoundException($uri);
            case Dispatcher::METHOD_NOT_ALLOWED:
                throw new MethodNotAllowedException($method);
            case Dispatcher::FOUND:
                $handler = $routeInfo[1];
                $parameters = $routeInfo[2];

                return $handler($request, $parameters);
        }
    }
1314353
def no_route_found(self, request):
        
        response_obj = OrderedDict()
        response_obj["status"] = False
        response_obj["exceptions"] = {
            "message": "No route found for {0} {1}".format(self.__method, self.__uri),
        }
        response_obj["request"] = {
            "method": self.__method,
            "path_info": self.__uri,
            "content": request.body.decode("utf-8")
        }
        response_obj["message"] = "We are sorry, but something went terribly wrong."

        return Response(response_obj, content_type="application/json", status=404, charset="utf-8")
1046933
public function postProcess(Request $request, Response $response)
    {
        if (empty($this->allowedOriginHosts) || !$request->hasHeader('HTTP_ORIGIN')) {
            return;
        }

        $originHost = $request->readHeader('HTTP_ORIGIN')->unsecure();
        foreach ($this->allowedOriginHosts as $allowedOriginHost) {
            if (preg_match('~' . $allowedOriginHost . '~', $originHost) === 1) {
                $response->addHeader('Access-Control-Allow-Origin', $originHost);
            }
        }
    }
508000
public function findByRequest(ServerRequestInterface $request)
    {
        $result = $this->findRouteByRequest($request, trim($request->getUri()->getPath(), '/'));

        if(!$result['route'])
            throw new RouteNotFoundException('Route for request '.$request->getMethod().' '.$request->getUri()->getPath().' does not exist');

        return $this->factory->createFinding($result['route'], $result['parameter'], $request);
    }
481089
protected function notFound()
    {
        $errmsg = sprintf('[%s][%s]method not found: %s:%s. handlers: %s', $this->request->getMethod(), UriHelper::getCurrentUrl(), get_class($this), $this->getLongName(), implode('|', $this->getHandleStack()));
        Ioc::logger('router')->error($errmsg);
        
        $handler = Ioc::get('notFoundHandler');
        return $handler($this->request, $this->response);
    }
397447
public function execute(Framework $framework, CliRequest $request, Response $response)
    {
        // Configure turbo
        $this->configure();
        
        // Save the settings
        $this->configurationManager->saveConfigurationFile();
        
        // Execute the DataSource setups
        $dataSourceManager = $framework->getDataSourceManager();
        foreach ($dataSourceManager->getDataSourceTypeClasses() as $type) {
            $dataSource = $dataSourceManager->getDataSource($type);
            $dataSource->setup();
        }
    }
1368408
private static function handleRequestNotFound () {
        $response = get_response();
        $response->clear();
        $response->statusCode(Response::HTTP_NOT_FOUND);
        $notFoundRoutes = self::$notFoundRoutes->getRoutes();
        if (!empty($notFoundRoutes)) {
            foreach ($notFoundRoutes as $notFoundRoute) {
                $routeResult = self::executeAction($notFoundRoute->getAction(), array_merge($_REQUEST, $notFoundRoute->getParameters()));
                if (isset($routeResult)) {
                    $response->content($routeResult);
                }
            }
            $response->send();
        }
        else {
            handle_error_code(Response::HTTP_NOT_FOUND);
        }
    }