Dancer2
view release on metacpan or search on metacpan
lib/Dancer2/Core/Route.pm view on Meta::CPAN
package Dancer2::Core::Route;
# ABSTRACT: Dancer2's route handler
$Dancer2::Core::Route::VERSION = '2.1.0';
use Moo;
use Dancer2::Core::Types;
use Module::Runtime 'use_module';
use Carp 'croak';
use List::Util 'first';
use Scalar::Util 'blessed';
use Ref::Util qw< is_regexpref >;
use Type::Registry;
our ( $REQUEST, $RESPONSE, $RESPONDER, $WRITER, $ERROR_HANDLER );
has name => (
is => 'ro',
isa => Str,
predicate => 'has_name',
);
has method => (
is => 'ro',
isa => Dancer2Method,
required => 1,
);
has code => (
is => 'ro',
required => 1,
isa => CodeRef,
);
has regexp => (
is => 'ro',
required => 1,
);
has spec_route => ( is => 'ro' );
has prefix => (
is => 'ro',
isa => Maybe [Dancer2Prefix],
predicate => 1,
);
has options => (
is => 'ro',
isa => HashRef,
trigger => \&_check_options,
predicate => 1,
);
sub _check_options {
my ( $self, $options ) = @_;
return 1 unless defined $options;
my @supported_options = (
qw/content_type agent user_agent content_length
path_info/
);
for my $opt ( keys %{$options} ) {
croak "Not a valid option for route matching: `$opt'"
if not( grep {/^$opt$/} @supported_options );
}
return 1;
}
# private attributes
has _should_capture => (
( run in 0.486 second using v1.01-cache-2.11-cpan-39bf76dae61 )