src/Application.php
public function add($middleware, string $pathConstraint = null): void
    {
        if (is_string($middleware)) {
            $middleware = $this->getContainer()->get($middleware);
        }

        if (!$middleware instanceof MiddlewareInterface) {
            throw new InvalidArgumentException('Middleware must be an instance of ' . MiddlewareInterface::class);
        }

        $this->middleware[] = new Middleware($middleware, $pathConstraint);
    }
public function add($middleware, string $pathConstraint = null): void
    {
        if (is_string($middleware)) {
            $middleware = $this->getContainer()->get($middleware);
        }

        if (!$middleware instanceof MiddlewareInterface) {
            throw new InvalidArgumentException('Middleware must be an instance of ' . MiddlewareInterface::class);
        }

        $this->middleware[] = new Middleware($middleware, $pathConstraint);
    }
Add all middleware to one array, it will be filtered based on the route once a request is being processed.

@param MiddlewareInterface|string $middleware
@param string|null $pathConstraint

@return void