private function getRouteByName($routeName)
    {
        if (isset($this->app->router) && $this->app->router instanceof \Laravel\Lumen\Routing\Router) {
            $router = $this->app->router;
        } else {
            // backward compatibility with lumen 5.3
            $router = $this->app;
        }
        foreach ($router->getRoutes() as $route) {
            if (isset($route['action']['as']) && $route['action']['as'] == $routeName) {
                return $route;
            }
        }
        $this->fail("Route with name '$routeName' does not exist");
        return null;
    }