File: 10_routematch.t

package info (click to toggle)
librouter-simple-perl 0.17-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 200 kB
  • sloc: perl: 325; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 518 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use strict;
use warnings;
use Router::Simple;
use Test::More;

my $r = Router::Simple->new();
$r->connect(
    'home',
    '/' => { controller => 'Root', action => 'show' },
    {
        method   => 'GET',
        host     => 'localhost',
        on_match => sub { 1 }
    }
);
my ( $ret, $route ) = $r->routematch(
    { HTTP_HOST => 'localhost', REQUEST_METHOD => 'GET', PATH_INFO => '/' }
);
is_deeply $route->method, ['GET'];
is_deeply $route->host, 'localhost';
is ref($route->on_match), 'CODE';

done_testing;