/** * Route path * * @param \Opis\HttpRouting\Path $path * * @return mixed */ public function route(BasePath $path) { $router = new AliasRouter($this->app->collect('RouteAliases')); $alias = $router->route(new AliasPath($path->path())); if ($alias !== null) { $path = new Path((string) $alias, $path->domain(), $path->method(), $path->isSecure(), $path->request()); } $this->path = $path; $result = parent::route($path); $response = $path->request()->response(); $response->body($result); $response->send(); return $result; }
/** * Route path * * @param BaseContext|Context $context * @return mixed */ public function route(BaseContext $context) { $this->currentPath = $context; $router = new AliasRouter(app()->getCollector()->getRouteAliases()); $alias = $router->route(new BaseContext($context->path())); if ($alias !== false) { $context = new Context((string) $alias, $context->domain(), $context->method(), $context->isSecure(), $context->request()); } $result = parent::route($context); /** @var \Opis\Http\Request $request */ $request = $context->request(); /** @var \Opis\Http\Response $response */ $response = $request->response(); $response->body($result); $response->send(); return $result; }