protected function setMiddlewareContext($context, MiddlewareCollection &$group = null)
    {
        if ($group === null) {
            $group = $this->middleware;
        }
        if ($group) {
            foreach ($group as &$value) {
                if ($value instanceof MiddlewareCollection) {
                    $this->setMiddlewareContext($context, $value);
                } elseif ($value instanceof MiddlewareInterface) {
                    $value->as($context);
                }
            }
        }
        return $this;
    }