File: Request.pm

package info (click to toggle)
libmason-plugin-routersimple-perl 0.07-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 136 kB
  • sloc: perl: 162; makefile: 7
file content (23 lines) | stat: -rw-r--r-- 679 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package Mason::Plugin::RouterSimple::Request;
BEGIN {
  $Mason::Plugin::RouterSimple::Request::VERSION = '0.07';
}
use Mason::PluginRole;

around 'construct_page_component' => sub {
    my ( $orig, $self, $compc, $args ) = @_;

    if ( $compc->router_object() ) {
        if ( defined( my $path_info = $self->path_info ) ) {
            if ( my $router_result = $compc->router_object->match($path_info) ) {
                $args = { router_result => $router_result, %$router_result, %$args };
            }
            else {
                $self->decline("'$path_info' did not match any routes");
            }
        }
    }
    return $self->$orig( $compc, $args );
};

1;