public function run(ServerRequestInterface $request = null) : void
    {
        if (null === $request) {
            $request = $this->getContainer()
                ->get(ServerRequestFactoryInterface::class)
                ->createServerRequestFromArray($_SERVER);
        }
        try {
            $this->response = $this->handleRequest($request);
        } catch (\Throwable $e) {
            if ($this->config->getParam('env') != 'prod') {
                throw $e;
            }
            $this->exceptionHandler->report($e);
            $this->response = $this->exceptionHandler->throwableToResponse($e);
        }
        
        $this->sendResponse($this->response);
        $this->terminate();
    }