Set middleware(s) on this route.
Will reset previously added middleware
If given argument is an array, add the list
Else, will be pushed as one middleware
@param mixed $middleware
@return $this
173801
public function setMiddleware($middleware, array $properties = array())
	{
		// reset on each call
		$this->properties['middleware'] = array();

		if(!is_array($middleware))
		{
			$this->properties['middleware'][] = array($middleware, $properties);
		}
		else
		{
			foreach($middleware as $m)
				$this->properties['middleware'][] = array($m);
		}

		return $this;
	}
1148749
public function middlewares(array $middlewares = []) {
        if (!$this->isGroupe) {
            end($this->virtualRoutes['*']);
            $lastKey = key($this->virtualRoutes['*']);
            $this->virtualRoutes['*'][$lastKey]['middlewares'] = $middlewares;
        } else {
            end($this->virtualRoutes);
            $lastKeyOfFirstRound = key($this->virtualRoutes);

            if (!$this->isGroupeMiddlewares) {
                end($this->virtualRoutes[$lastKeyOfFirstRound]);
                $lastKeyOfSecondRound = key($this->virtualRoutes[$lastKeyOfFirstRound]);
                $this->virtualRoutes[$lastKeyOfFirstRound][$lastKeyOfSecondRound]['middlewares'] = $middlewares;
            } else {
                $this->isGroupe = FALSE;

                foreach ($this->virtualRoutes[$lastKeyOfFirstRound] as &$route) {
                    $hasMiddleware = end($route);
                    if (!is_array($hasMiddleware)) {
                        $route['middlewares'] = $middlewares;
                    } else {
                        foreach ($middlewares as $middleware) {
                            $route['middlewares'][] = $middleware;
                        }
                    }
                }
            }
        }
    }
423769
public function middleware($middleware = null)
    {
        if (is_null($middleware)) {
            return $this->middleware;
        }

        if (is_string($middleware)) {
            $middleware = func_get_args();
        }

        $this->middleware = array_unique(array_merge($this->middleware, $middleware));

        return $this;
    }
691618
public function addMiddleware(string $name, string $middleware): void{
        $this->middleware[$name] = $middleware;
    }
1044211
public static function create(array $middlewares)
    {
        if (empty($middlewares)) {
            throw new StackException('Middlewares array cannot be empty.');
        }

        $stack = new static();

        $stack->middlewares = $middlewares;

        return $stack;
    }
747968
public function withMiddleware(string $alias, string $middleware)
    {
        if (! class_exists($middleware)) {
            throw new \Exception("Middleware not found. [{$middleware}]");
        }

        $reflection = new \ReflectionClass($middleware);
        $interfaces = $reflection->getInterfaceNames();

        $isFind = false;
        foreach ($interfaces as &$interface) {
            if ($interface === MiddlewareInterface::class) {
                $isFind = true;
                break;
            }
        }

        if (! $isFind) {
            throw new \Exception("Middleware must instanceof Weipaitang\Middleware\MiddlewareInterface. [{$middleware}]");
        }

        unset($reflection, $interfaces);

        $this->middlewares[$alias] = $middleware;

        return $this;
    }
1333094
public function middleware($middlewares, bool $addToFront = false): MiddlewareAwareInterface
    {
        if (! is_array($middlewares)) {
            $middlewares = [$middlewares];
        }

        foreach ($middlewares as $middleware) {
            if ($addToFront) {
                //prepend Middleware
                array_unshift($this->middlewares, $middleware);
            } else {
                // append Middleware
                array_push($this->middlewares, $middleware);
            }
        }

        return $this;
    }
1355740
public function addMiddleware($middleware, $priority = PriorityQueue::NORMAL)
    {
        if (is_array($middleware) && isset($middleware['priority'])) {
            $priority = $middleware['priority'];
        }

        $this->getMiddlewares()->insert($middleware, $priority);

        return $this;
    }
721995
public function addMiddleware($middleware, $priority = PriorityQueue::NORMAL)
    {
        $this->getMiddlewares()->insert($middleware, $priority);

        return $this;
    }
578621
public function removeMiddleware(MiddlewareInterface $middleware)
    {
        $this->stack = $this->stack->withoutMiddleware($middleware);
        return $this;
    }
506717
public function pipeOnTop($middleware): self
    {
        array_unshift($this->middlewares, $this->decorate($middleware));

        return $this;
    }
605879
public function addMiddleware(callable $middleware, string $type = self::BEFORE)
  {
;    $type = self::validateMiddlewareType($type);
    $this->middlewares[$type][] = $middleware;
  }
328303
public function add(...$middleware) : self
    {
        foreach ($middleware as $m) {
            if ($m instanceof TusMiddleware) {
                $this->globalMiddleware[get_class($m)] = $m;
            } elseif (is_string($m)) {
                $this->globalMiddleware[$m] = new $m;
            }
        }

        return $this;
    }
1285002
public function prependMiddlewareToGroup($group, $middleware)
    {
        if (isset($this->middlewareGroups[$group]) && ! in_array($middleware, $this->middlewareGroups[$group])) {
            array_unshift($this->middlewareGroups[$group], $middleware);
        }

        return $this;
    }
589409
public function addMiddleware($middleware, bool $prepend = false)
    {
        if (!is_array($middleware)) {
            $middleware = [$middleware];
        }

        if ($prepend) {
            $this->middleware = array_merge($middleware, $this->middleware);
        } else {
            $this->middleware = array_merge($this->middleware, $middleware);
        }

        $this->middleware = array_unique($this->middleware, SORT_REGULAR);
    }
296133
public function withoutMiddleware($middleware = null)
    {
        if (is_null($middleware)) {
            $this->app->instance('middleware.disable', true);

            return $this;
        }

        foreach ((array) $middleware as $abstract) {
            $this->app->instance($abstract, new class {
                public function handle($request, $next)
                {
                    return $next($request);
                }
            });
        }

        return $this;
    }
1281242
public function prepend($middleware)
    {
        if (is_array($middleware)) {
            $this->queue = array_merge($middleware, $this->queue);

            return $this;
        }
        array_unshift($this->queue, $middleware);

        return $this;
    }