Laravel\Lumen\Concerns\RoutesRequests::addRoute PHP Method

addRoute() public method

Add a route to the collection.
public addRoute ( array | string $method, string $uri, mixed $action ) : void
$method array | string
$uri string
$action mixed
return void
    public function addRoute($method, $uri, $action)
    {
        $action = $this->parseAction($action);
        if (isset($this->groupAttributes)) {
            if (isset($this->groupAttributes['prefix'])) {
                $uri = trim($this->groupAttributes['prefix'], '/') . '/' . trim($uri, '/');
            }
            if (isset($this->groupAttributes['suffix'])) {
                $uri = trim($uri, '/') . rtrim($this->groupAttributes['suffix'], '/');
            }
            $action = $this->mergeGroupAttributes($action);
        }
        $uri = '/' . trim($uri, '/');
        if (isset($action['as'])) {
            $this->namedRoutes[$action['as']] = $uri;
        }
        if (is_array($method)) {
            foreach ($method as $verb) {
                $this->routes[$verb . $uri] = ['method' => $verb, 'uri' => $uri, 'action' => $action];
            }
        } else {
            $this->routes[$method . $uri] = ['method' => $method, 'uri' => $uri, 'action' => $action];
        }
    }