summary refs log tree commit diff
path: root/lib/Plack/Middleware/Debug
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-08-21 17:15:09 +0200
committerfranck cuny <franck@lumberjaph.net>2010-08-21 17:15:09 +0200
commit9090ab074178097f73d54c583a40a022183d9978 (patch)
tree2add4d86170d9d36bb8b6beab3fe6af2e1e9f0a9 /lib/Plack/Middleware/Debug
parentnew release (diff)
downloaddancer-debug-9090ab074178097f73d54c583a40a022183d9978.tar.gz
add apps panel, rewrite routes one master
Diffstat (limited to 'lib/Plack/Middleware/Debug')
-rw-r--r--lib/Plack/Middleware/Debug/Dancer/App.pm27
-rw-r--r--lib/Plack/Middleware/Debug/Dancer/Routes.pm33
2 files changed, 45 insertions, 15 deletions
diff --git a/lib/Plack/Middleware/Debug/Dancer/App.pm b/lib/Plack/Middleware/Debug/Dancer/App.pm
new file mode 100644
index 0000000..424c1eb
--- /dev/null
+++ b/lib/Plack/Middleware/Debug/Dancer/App.pm
@@ -0,0 +1,27 @@
+package Plack::Middleware::Debug::Dancer::App;
+
+use strict;
+use warnings;
+
+use parent qw/Plack::Middleware::Debug::Base/;
+use Dancer::App;
+
+sub run {
+    my ( $self, $env, $panel ) = @_;
+
+    return sub {
+        my $applications;
+
+        foreach my $app ( Dancer::App->applications ) {
+            $applications->{ $app->{name} } = $app->{settings};
+        }
+
+        $panel->title('Applications');
+        $panel->nav_title('Applications');
+        $panel->content(
+            sub { $self->render_hash( $applications, [ keys %$applications ] ) }
+        );
+    };
+}
+
+1;
diff --git a/lib/Plack/Middleware/Debug/Dancer/Routes.pm b/lib/Plack/Middleware/Debug/Dancer/Routes.pm
index d214370..aeed516 100644
--- a/lib/Plack/Middleware/Debug/Dancer/Routes.pm
+++ b/lib/Plack/Middleware/Debug/Dancer/Routes.pm
@@ -5,32 +5,35 @@ package Plack::Middleware::Debug::Dancer::Routes;
 use strict;
 use warnings;
 use parent qw(Plack::Middleware::Debug::Base);
-use Dancer::Session;
 
 sub run {
     my ( $self, $env, $panel ) = @_;
 
     return sub {
-        my $routes = Dancer::Route::Registry->routes();
-        my $hash_routes;
-
-        foreach my $method ( keys %$routes ) {
-            map {
-                my $name = $_->{method} . ' ' . $_->{route};
-                $hash_routes->{$name} = {
-                    method  => $_->{method},
-                    options => $_->{options},
-                    params  => $_->{params},
-                    route   => $_->{route}
-                };
-            } @{ $routes->{$method} };
+        my $hash_routes = {};
+        foreach my $app ( Dancer::App->applications ) {
+            my $routes = $app->{registry}->{routes};
+            foreach my $method (keys %$routes) {
+                foreach (@{$routes->{$method}}) {
+                    $hash_routes->{$method}->{$_->{_compiled_regexp}} = $_->{_params};
+                }
+            }
+                # map {
+                #     my $name = $_->{method} . ' ' . $_->{route};
+                #     $hash_routes->{$name} = {
+                #         method  => $_->{method},
+                #         options => $_->{options},
+                #         params  => $_->{params},
+                #         route   => $_->{route}
+                #     };
+                # } @{ $routes->{$method} };
         }
 
         $panel->title('Dancer::Route');
         $panel->nav_subtitle(
             "Dancer::Route (" . ( keys %$hash_routes ) . ")" );
         $panel->content(
-            sub { $self->render_hash( $hash_routes, [ keys %$hash_routes ] ) }
+            sub { $self->render_hash( $hash_routes, [keys %$hash_routes] ) }
         );
     };
 }