Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: fac02388fb
Fetching contributors…

Cannot retrieve contributors at this time

file 33 lines (28 sloc) 0.792 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
package Angelos::Dispatcher::Routes::Builder;
use Angelos::Class;
use HTTP::Router;
use Angelos::Exceptions;
use Angelos::Utils;

sub build_from_config {
    my $self = shift;

    my $conf_path = $self->_route_config;
    Angelos::Exception->throw(
        message => "routes.pl doesn't exit: $conf_path" )
        unless -f $conf_path;
    $self->build($conf_path);
}

sub build {
    my ( $self, $conf ) = @_;
    my $content = $conf->slurp;
    my $router = eval $content; ##no critic
    if ( my $e = $@ ) {
        Angelos::Exception->throw(
            message => "Can't load routes.pl: $conf. error: $e" );
    }
    my @routeset = $router->routeset;
    \@routeset;
}

sub _route_config {
    Angelos::Utils::context->project_structure->routes_config_file_path;
}

__END_OF_CLASS__
Something went wrong with that request. Please try again.