src/RouteCollector.php
public function addRoute($httpMethod, $route, $handler, array $middleware = [])
    {
        if (!$handler instanceof HandlerContainer) {
            $handler = new HandlerContainer($handler, array_merge($this->middlewareStack, $middleware));
        } else {
            $handler->addMiddleware(array_merge($this->middlewareStack, $middleware));
        }
        
        $handler = serialize($handler);
        
        $route = $this->currentGroupPrefix . $route;
        $routeDatas = $this->routeParser->parse($route);
        foreach ((array) $httpMethod as $method) {
            foreach ($routeDatas as $routeData) {
                $this->dataGenerator->addRoute($method, $routeData, $handler);
            }
        }
    }
public function addRoute($httpMethod, $route, $handler, array $middleware = [])
    {
        if (!$handler instanceof HandlerContainer) {
            $handler = new HandlerContainer($handler, array_merge($this->middlewareStack, $middleware));
        } else {
            $handler->addMiddleware(array_merge($this->middlewareStack, $middleware));
        }
        
        $handler = serialize($handler);
        
        $route = $this->currentGroupPrefix . $route;
        $routeDatas = $this->routeParser->parse($route);
        foreach ((array) $httpMethod as $method) {
            foreach ($routeDatas as $routeData) {
                $this->dataGenerator->addRoute($method, $routeData, $handler);
            }
        }
    }
Adds a route to the collection.

The syntax used in the $route string depends on the used route parser.

@param string|string[] $httpMethod      HTTP Verb(s) for this route
@param string $route                    The route
@param mixed  $handler                  Either a handler specified Laravel style: "ControllerClass@MethodName"
or a pregenerated HandlerContainer object
@param Middleware|string[] $middleware  List of middleware (Middleware objects or named middleware) to add to
this route