summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Narwhal.pm3
-rw-r--r--lib/Narwhal/RouteBuilder/HTTPMethod.pm25
2 files changed, 11 insertions, 17 deletions
diff --git a/lib/Narwhal.pm b/lib/Narwhal.pm
index 0a7a24e..612c2b9 100644
--- a/lib/Narwhal.pm
+++ b/lib/Narwhal.pm
@@ -1,6 +1,5 @@
package Narwhal;
use OX;
-use Narwhal::RouteBuilder::HTTPMethod;
with 'OX::Role::WithAppRoot';
@@ -41,7 +40,7 @@ component Kioku => 'Narwhal::Component::Model', (
extra_args => depends_on('/Config/kioku_extra_args'),
);
-router as {
+router ['Narwhal::RouteBuilder::HTTPMethod'], as {
route '/' => 'redirect.permanent', (
to => '/page/main',
);
diff --git a/lib/Narwhal/RouteBuilder/HTTPMethod.pm b/lib/Narwhal/RouteBuilder/HTTPMethod.pm
index 9631616..33fe893 100644
--- a/lib/Narwhal/RouteBuilder/HTTPMethod.pm
+++ b/lib/Narwhal/RouteBuilder/HTTPMethod.pm
@@ -3,21 +3,6 @@ use Moose;
with 'OX::RouteBuilder';
-sub import {
- my $meta = Class::MOP::class_of(caller);
- $meta->add_route_builder(
- class => __PACKAGE__,
- route_spec => sub {
- my $spec = shift;
- return if ref($spec);
- return unless $spec =~ /^http-method:(\w+)$/;
- return {
- action => $1,
- };
- },
- );
-}
-
sub compile_routes {
my $self = shift;
@@ -59,6 +44,16 @@ sub compile_routes {
];
}
+sub parse_action_spec {
+ my $self = shift;
+ my ($action_spec) = @_;
+ return if ref($action_spec);
+ return unless $action_spec =~ /^http-method:(\w+)$/;
+ return {
+ action => $1,
+ };
+}
+
__PACKAGE__->meta->make_immutable;
no Moose;