| HTTP-Router documentation | Contained in the HTTP-Router distribution. |
HTTP::Router::Debug
use HTTP::Router;
use HTTP::Router::Debug;
my $router = HTTP::Router->define(...);
print $router->routing_table->draw;
# or
$router->show_table;
Returns a Text::SimpleTable object for routing information.
Constructs and Prints a table for routing information.
Takatoshi Kitano <kitano.tk@gmail.com>
NAKAGAWA Masaki <masaki@cpan.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| HTTP-Router documentation | Contained in the HTTP-Router distribution. |
package HTTP::Router::Debug; use strict; use warnings; use Text::SimpleTable; our @EXPORT = qw(show_table routing_table); sub import { require HTTP::Router; no strict 'refs'; for my $name (@EXPORT) { *{"HTTP::Router::$name"} = \&{$name}; } } sub show_table { my $table = $_[0]->routing_table->draw; print "$table\n"; } sub routing_table { my $self = shift; my $table = Text::SimpleTable->new( [qw(35 path) ], [qw(10 method) ], [qw(10 controller)], [qw(10 action) ], ); for my $route ($self->routes) { my $method = $route->conditions->{method}; $method = [ $method ] unless ref $method; $table->row( $route->path, join(',', @$method), $route->params->{controller}, $route->params->{action} ); } return $table; } 1;