/**
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @param callable|null $next
  * @return ResponseInterface
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null)
 {
     if (!$this->session->isStarted()) {
         $this->session->start();
     }
     $request = $request->withAttribute('session', $this->session);
     if ($next) {
         return $next($request, $response);
     }
     return $response;
 }