How to access the $container within middleware class in Slim v3? : <p>I've been reading that in Slim v2, $app was bound to the middleware class. I'm finding this not to be the case in v3? Below is my middleware class, but I'm just getting undefined:</p>

<pre><code>&lt;?php
namespace CrSrc\Middleware;

class Auth
{
    /**
     * Example middleware invokable class
     *
     * @param  \Psr\Http\Message\ServerRequestInterface $request  PSR7 request
     * @param  \Psr\Http\Message\ResponseInterface      $response PSR7 response
     * @param  callable                                 $next     Next middleware
     *
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function __invoke($request, $response, $next)
    {
        // before

var_dump($this-&gt;getContainer()); // method undefined
var_dump($this-&gt;auth); exit; // method undefined
        if (! $this-&gt;get('auth')-&gt;isAuthenticated()) {
            // Not authenticated and must be authenticated to access this resource
            return $response-&gt;withStatus(401);
        }

        // pass onto the next callable
        $response = $next($request, $response);

        // after


        return $response;
    }
}
</code></pre>

<p>What's the correct way to access the DI container within middleware? I'm guessing there ought to be a way?</p>
