protected function addMiddlewareToStack(Onion $onion, array $middleware): void
	{
		if(empty($middleware) === false)
		{
			// Resolve middleware

			$resolved = [];

			foreach($middleware as $layer)
			{
				$layer = $this->resolveMiddleware($layer);

				$resolved[$layer['name']][] = $layer;
			}

			// Add ordered middleware to stack

			foreach($this->orderMiddlewareByPriority($resolved) as $name)
			{
				foreach($name as $layer)
				{
					$onion->addLayer($layer['middleware'], $layer['parameters']);
				}
			}
		}
	}