Execute the http request
And return the context
@param ServerRequest|null $request
@return Runtime\Context
@throws RouteNotFoundException
183851
public function request(ServerRequest $request = null)
    {
        $finding = $this->map->findByRequest($request = ($request ? : $this->request));

        return $this->run($finding);
    }
468395
public function execute($routeName, array $parameters = array(), ServerRequest $request = null)
    {
        // expect it as route name
        if(!is_string($routeName))
            throw new Exception\InvalidArgumentException('Argument 1 must be [string]');

        $route = $this->map->findRoute($routeName);

        if(!$route)
            throw new RouteNotFoundException('Route [' . $routeName . '] does not exist.');

        return $this->run($this->map->getFactory()->createFinding($route, $parameters, $request));
    }
81361
protected function _checkUrl(ServerRequestInterface $request)
    {
        return $this->_getUrlChecker()->check(
            $request,
            $this->getConfig('loginUrl'),
            (array)$this->getConfig('urlChecker')
        );
    }
319265
public function route($request = NULL)
    {
        $matchedResource = NULL;
        if (!$request) {
            $request = new Request();
        }
        foreach ($this->resources as $className => $resourceMetadata) {
            foreach ($resourceMetadata->getUri() as $index => $uri) {
                $uriRegex = '|^'.$uri.'$|';
                if (
                    ($matchedResource == NULL || $matchedResource[0]->getPriority() < $resourceMetadata->getPriority())
                &&
                    preg_match($uriRegex, $request->getUri(), $params)
                ) {
                    array_shift($params);
                    $uriParams = $resourceMetadata->getUriParams($index);
                    if ($uriParams) { // has params within URI
                        foreach ($uriParams as $key => $name) {
                            $params[$name] = $params[$key];
                        }
                    }
                    $matchedResource = array($resourceMetadata, $params);
                }
            }
        }
        if ($matchedResource) {
            $request->setParams($matchedResource[1]);

            return $matchedResource[0];
        } else {
            throw new NotFoundException(sprintf('Resource matching URI "%s" not found', $request->uri));
        }
    }
907329
protected static function currentRequest(HTTPRequest $request = null)
    {
        // Ensure we only use a registered HTTPRequest and don't
        // incidentally construct a singleton
        if (!$request && Injector::inst()->has(HTTPRequest::class)) {
            $request = Injector::inst()->get(HTTPRequest::class);
        }
        return $request;
    }
479953
public function queryAction(Request $request)
    {
        $geolocatorName = $request->get('providerName');
        $query = $request->get('query');

        try {
            $geolocator = $this->geolocatorManager->get($geolocatorName);
        } catch (GeolocatorNotFoundException $e) {
            throw new NotFoundHttpException(
                sprintf(
                    'Wrapped "%s"',
                    $e->getMessage()
                ),
                $e
            );
        }

        $res = $geolocator->locate($query);

        return new JsonResponse(['_embedded' => ['locations' => $res->toArray()]]);
    }
424130
public function handleRequest($request)
    {
        list ($route, $params) = $request->resolve();
        $this->requestedRoute = $route;
        $result = $this->runAction($route, $params);
        if ($result instanceof Response) {
            return $result;
        } else {
            $response = $this->getResponse();
            $response->exitStatus = $result;

            return $response;
        }
    }
136158
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        /**
         * If request is modified by a middleware, and as ServerRequestInterface is immutable, given $request must
         * replace current ServerRequestInterface in RequestHandler PSR-11 container.
         */
        $this->container->set("request", $request);

        $middlewareEntry = current($this->middlewareSequence);
        next($this->middlewareSequence);

        // If middleware sequence is exhausted, controller is instantiated and run.
        if ($middlewareEntry === false) {

            /**
             * @var Route $route
             */
            $route = $this->container->get("route");

            $controllerData = explode("::", $route->controller);
            if (count($controllerData) !== 2) {

                throw new RuntimeException("Invalid controller declaration for route {$route->name} (expecting '\\Namespace\\Class::method' format)");

            }

            $controllerClass = $controllerData[0];
            if (class_exists($controllerClass) === false) {

                throw new RuntimeException("Invalid controller declaration for route {$route->name} (unknown class {$controllerClass})");

            }

            /**
             * @var $controller AbstractController
             */
            $controller = new $controllerClass($this->container);

            $controllerMethod = $controllerData[1];
            if (method_exists($controller, $controllerMethod) === false) {

                throw new BadMethodCallException("{$controllerClass}::{$controllerMethod} declared in routes doesn't exists in {$controllerClass}");

            }

            /**
             * @var $response ResponseInterface
             */
            $response = $controller->{$controllerMethod}();
            if (($response instanceof ResponseInterface) === false) {

                throw new LogicException("Method {$controllerMethod} must return an instance of PSR-7 ResponseInterface");

            }

            return $response;

        } else {

            $middlewareFQCN = is_array($middlewareEntry) ? $middlewareEntry[0] : $middlewareEntry;
            $middlewareParams = is_array($middlewareEntry) && count($middlewareEntry) > 1 ? $middlewareEntry[1] : null;

            /**
             * @var $middleware MiddlewareInterface
             */
            $middleware = new $middlewareFQCN($middlewareParams);
            if (($middleware instanceof MiddlewareInterface) === false) {

                throw new LogicException("Middleware {$middlewareFQCN} must implements PSR-11 MiddlewareInterface");

            }

            return $middleware->process($request, $this);

        }
    }
1012360
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        if(isset($this->middlewares[$this->index]))
        {
            $middleware = $this->middlewares[$this->index];
            if($middleware instanceof RequestHandlerInterface)
            {
                $requestHandler = $middleware;
            }
            else
            {
                $requestHandler = RequestContext::getServerBean($middleware);
            }
        }
        else
        {
            return RequestContext::get('response');
        }
        return $requestHandler->process($request, $this->next());
    }
248807
public function execute(Request $request = null)
    {
        $request = $request ?: $this->request;

        $this->dispatcher->dispatch($request, $this->response);

    }
428558
public function create(ServerRequestInterface $request, Route $route)
    {
        $this->uriGenerator->setRequest($request);
        return new Context($request, $route, $this->uriGenerator);
    }
845434
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        return $this->dispatchRoute($this->resolve($request), $request);
    }
1367020
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $user_id = (int) $request->getParsedBody()['user_id'];

        $user = $this->user_service->find($user_id);

        if ($user === null) {
            throw new NotFoundHttpException('User ID ' . $user_id . ' not found');
        }

        if ($this->user->id() !== $user_id) {
            Log::addAuthenticationLog('Masquerade as user: ' . $user->userName());
            Auth::login($user);
            Session::put('masquerade', '1');
        }

        return response('', StatusCodeInterface::STATUS_NO_CONTENT);
    }
689779
public function handleRequest(ServerRequestInterface $request): ResponseInterface
    {
        $this->request = $request;
        $action = $request->getQueryParams()['action'] ?? $request->getParsedBody()['action'] ?? 'overview';
        $this->initializeView($action);

        $result = call_user_func_array([$this, $action . 'Action'], [$request]);
        if ($result instanceof ResponseInterface) {
            return $result;
        }
        $this->moduleTemplate->setContent($this->view->render());
        return new HtmlResponse($this->moduleTemplate->renderContent());
    }
82237
public function route(ServiceRequest $request) {
    list ($controller, $method, $params) = $this->routeController($request);
    
    $this->validateController($controller, $method, $params);
    
    $this->runController(
      $controller, $method, $params
    );
    
    return $this->response;
  }
1350960
public function route(ServerRequestInterface $request)
    {

        /** @var Route[] $routes */
        $routes = array_reverse($this->routes);
        foreach ($routes as $route) {

            $path = $request->getUri()->getPath();
            $baseUri = $this->getOption('baseUri', '');

            $len = strlen($baseUri);
            if ($len > 0) {

                if (strncmp($baseUri, $path, $len) !== 0)
                    continue;

                $path = substr($path, $len);
            }

            if (empty($path))
                $path = '/';

            $vars = null;
            if (!in_array($request->getMethod(), $route->getMethods())
                || ($vars = $route->match($path)) === false)
                continue;

            $subRequest = $request;
            foreach ($vars as $key => $value)
                $subRequest = $subRequest->withAttribute($key, $value);

            $this->app->prepend(function($request, $response, $next) use ($route, $subRequest) {

                $handler = $this->app->prepareMiddleware($route->getHandler());
                return $handler($subRequest, $response, $next);
            });
        }

        return $this;
    }
441262
public static function fromPsrRequest(ServerRequestInterface $request)
    {
        $uri    = $request->getUri();
        $server = $request->getServerParams();

        return new self(
            $uri->getPath(),
            $request->getMethod(),
            $uri->getQuery(),
            $uri->getHost(),
            $uri->getScheme(),
            $uri->getPort() ?: (isset($server['SERVER_PORT']) ? $server['SERVER_PORT'] : 80)
        );
    }