/** * Execute * * @param HttpRequest|null $request * * @return mixed */ public function run(HttpRequest $request = null) { if ($request === null) { $request = HttpRequest::fromGlobals(); } $this->httpRequestInstance = $request; $context = new Context($request->path(), $request->host(), $request->method(), $request->isSecure(), $request); return $this->getHttpRouter()->route($context); }
/** * Return the underlying HTTP request object * * @return \Opis\Http\Request */ public function request() { if (!isset($this->instances['request'])) { $this->instances['request'] = HttpRequest::fromGlobals(); } return $this->instances['request']; }