diff --git a/lib/Routes/Tiny.pm b/lib/Routes/Tiny.pm index 44f0cb0..c697e3b 100644 --- a/lib/Routes/Tiny.pm +++ b/lib/Routes/Tiny.pm @@ -17,6 +17,7 @@ sub new { bless $self, $class; $self->{strict_trailing_slash} = $params{strict_trailing_slash}; + $self->{default_method} = $params{default_method}; $self->{parent_pattern} = undef; $self->{patterns} = []; @@ -33,6 +34,7 @@ sub add_route { $pattern = $self->_build_pattern( strict_trailing_slash => $self->{strict_trailing_slash}, + default_method => $self->{default_method}, routes => $self, pattern => $pattern, @args diff --git a/lib/Routes/Tiny/Pattern.pm b/lib/Routes/Tiny/Pattern.pm index 6bc462b..87dc38b 100644 --- a/lib/Routes/Tiny/Pattern.pm +++ b/lib/Routes/Tiny/Pattern.pm @@ -23,7 +23,7 @@ sub new { $self->{name} = $params{name}; $self->{defaults} = $params{defaults}; $self->{arguments} = $params{arguments}; - $self->{method} = $params{method}; + $self->{method} = $params{method} || $params{default_method}; $self->{pattern} = $params{pattern}; $self->{constraints} = $params{constraints} || {}; $self->{routes} = $params{routes};