Skip to content

Commit 9090ab0

Browse files
author
franck cuny
committed
add apps panel, rewrite routes one
1 parent 693e227 commit 9090ab0

File tree

2 files changed

+45
-15
lines changed

2 files changed

+45
-15
lines changed
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package Plack::Middleware::Debug::Dancer::App;
2+
3+
use strict;
4+
use warnings;
5+
6+
use parent qw/Plack::Middleware::Debug::Base/;
7+
use Dancer::App;
8+
9+
sub run {
10+
my ( $self, $env, $panel ) = @_;
11+
12+
return sub {
13+
my $applications;
14+
15+
foreach my $app ( Dancer::App->applications ) {
16+
$applications->{ $app->{name} } = $app->{settings};
17+
}
18+
19+
$panel->title('Applications');
20+
$panel->nav_title('Applications');
21+
$panel->content(
22+
sub { $self->render_hash( $applications, [ keys %$applications ] ) }
23+
);
24+
};
25+
}
26+
27+
1;

lib/Plack/Middleware/Debug/Dancer/Routes.pm

+18-15
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,35 @@ package Plack::Middleware::Debug::Dancer::Routes;
55
use strict;
66
use warnings;
77
use parent qw(Plack::Middleware::Debug::Base);
8-
use Dancer::Session;
98

109
sub run {
1110
my ( $self, $env, $panel ) = @_;
1211

1312
return sub {
14-
my $routes = Dancer::Route::Registry->routes();
15-
my $hash_routes;
16-
17-
foreach my $method ( keys %$routes ) {
18-
map {
19-
my $name = $_->{method} . ' ' . $_->{route};
20-
$hash_routes->{$name} = {
21-
method => $_->{method},
22-
options => $_->{options},
23-
params => $_->{params},
24-
route => $_->{route}
25-
};
26-
} @{ $routes->{$method} };
13+
my $hash_routes = {};
14+
foreach my $app ( Dancer::App->applications ) {
15+
my $routes = $app->{registry}->{routes};
16+
foreach my $method (keys %$routes) {
17+
foreach (@{$routes->{$method}}) {
18+
$hash_routes->{$method}->{$_->{_compiled_regexp}} = $_->{_params};
19+
}
20+
}
21+
# map {
22+
# my $name = $_->{method} . ' ' . $_->{route};
23+
# $hash_routes->{$name} = {
24+
# method => $_->{method},
25+
# options => $_->{options},
26+
# params => $_->{params},
27+
# route => $_->{route}
28+
# };
29+
# } @{ $routes->{$method} };
2730
}
2831

2932
$panel->title('Dancer::Route');
3033
$panel->nav_subtitle(
3134
"Dancer::Route (" . ( keys %$hash_routes ) . ")" );
3235
$panel->content(
33-
sub { $self->render_hash( $hash_routes, [ keys %$hash_routes ] ) }
36+
sub { $self->render_hash( $hash_routes, [keys %$hash_routes] ) }
3437
);
3538
};
3639
}

0 commit comments

Comments
 (0)