Trying to simplify routing code

Hi

In my routing i have a callable like this:
> $defaultAdminRouting = function ($routes) {

              $routes->extensions(['html']);
              $routes->connect('/', ['action' => 'index']);
              $routes->connect('/:action/*');
          };

I’m using it something like this:

Router::prefix(‘admin’, function ($routes) {
$defaultAdminRouting = function ($routes) {
$routes->extensions([‘html’]);
$routes->connect(’/’, [‘action’ => ‘index’]);
$routes->connect(’/:action/*’);
};

   $routes->connect('/', ['controller' => 'Admin', 'action' => 'index']);
   $routes->scope('/anotherlevel', ['prefix' => 'admin/anotherlevel', 'controller' => 'anotherlevel'], $defaultAdminRouting);     
   $routes->scope('/anotherotherlevel', ['prefix' => 'admin/anotherlevel', 'controller' => 'anotherlevel'], $defaultAdminRouting); 

}

The problem is that i keep having to repeat the following code for each prefix:

  >   $defaultAdminRouting = function ($routes) {
          $routes->extensions(['html']);
          $routes->connect('/', ['action' => 'index']);
          $routes->connect('/:action/*');
      };

Is there a way to declare this somewhere in the routes.php so that i can use it for any $routes->scope call?

It would really simplify my code if i could do something like that.

I feel like it should be quite simple but i just cant figure it out. Would very much appreciate some guidance.

Cheers.