When I parse html response body I want to find route names for all links found in the body. I use next code snippet:
my $url = Mojo::URL->new( $got );
my $method = uc( $url->query->clone->param( '_method' ) || 'GET' );
my $c = $t->app->build_controller;
my $m = Mojolicious::Routes::Match->new( root => $t->app->routes );
$m->find( $c => { method => $method, path => $url->path } );
Then $m->endpoint->name
gives me the name of route.
But is there more simple way to find route name by given path?
I am looking for something like: $app->routes->find( '/api/v/users/146/link/7QRgs' )
which should return user_hash_check
because I have next route:
$guest->get( '/users/:id/link/:hash', 'user_hash_check' )->to( 'user#hash_check' );