1use strict; 2use warnings; 3use Router::Simple; 4use Test::More; 5 6my $r = Router::Simple->new(); 7$r->submapper('/account', {controller => 'Account'}) 8 ->connect('/login', {action => 'login'}) 9 ->connect('/logout', {action => 'logout'}) 10 ->submapper('/profile') # nested submapper 11 ->connect('/show', {action => 'profile_show'}) 12; 13 14$r->submapper('/entry/{id:[0-9]+}', {controller => 'Entry'}) 15 ->connect('/show', {action => 'show'}) 16 ->connect('/edit', {action => 'edit'}); 17 18is_deeply( 19 $r->match( +{ PATH_INFO => '/account/login', HTTP_HOST => 'localhost', REQUEST_METHOD => 'GET' } ) || undef, 20 { 21 controller => 'Account', 22 action => 'login', 23 } 24); 25 26is_deeply( 27 $r->match( +{ PATH_INFO => '/account/profile/show', HTTP_HOST => 'localhost', REQUEST_METHOD => 'GET' } ) || undef, 28 { 29 controller => 'Account', 30 action => 'profile_show', 31 } 32); 33 34is_deeply( 35 $r->match( +{ PATH_INFO => '/entry/49/edit', HTTP_HOST => 'localhost', REQUEST_METHOD => 'GET' } ) || undef, 36 { 37 controller => 'Entry', 38 action => 'edit', 39 id=>49, 40 } 41); 42 43done_testing; 44