File: prof.pl

package info (click to toggle)
librouter-simple-perl 0.17-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 200 kB
  • sloc: perl: 325; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 1,417 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use strict;
use warnings;
use Router::Simple::Declare;

my $path = shift @ARGV || '/account/login';

my $rs = router {
    # path and params
    connect '/' => { controller => 'Root', action => 'index' };

    # path, conditions, and params
    connect '/home', { controller => 'Home', action => 'show' }, { method => 'GET' };
    connect '/date/{year:\d{4}}',
        { controller => 'Date', action => 'by_year' };

    # path, params, and nesting
    submapper('/account', { controller => 'Account' })
        ->connect('/login',  {action => 'login'})
        ->connect('/logout', {action => 'logout'});

    # path nesting
    submapper('/account')
        ->connect('/signup',  {controller => 'User', action => 'register'})
        ->connect('/logout', {controller => 'Account', action => 'logout'});

    # conditions nesting
    submapper('/', {}, { method => 'GET' })
        ->connect('/search' => {controller => 'Items', action => 'search'})
        ->connect('/tags'   => {controller => 'Tags',  action => 'index'});

    # params nesting
    submapper('/', { 'controller' => 'Account' })
        ->connect('/login', {action => 'login'})
        ->connect('/logout', {action => 'logout'})
        ->connect('/signup', {action => 'signup'});

    # match only
    connect '/{controller}/{action}/{id}.{format}';
    connect '/{controller}/{action}/{id}';
};

for my $i (0..10000) {
    $rs->match($path);
}