Ado

 view release on metacpan or  search on metacpan

lib/Ado.pm  view on Meta::CPAN

        }
    }

    return $app;
}

#load routes defined in ado.conf
sub load_routes {
    my ($app, $config_routes) = @_;
    $config_routes ||= $app->config('routes') || [];
    my $routes = $app->routes;

    # Hide Ado::Control methods and attributes from router.
    $routes->hide(
        qw(
          debug config require_format list_for_json
          validate_input
          )
    );

    foreach my $route (@$config_routes) {
        my ($pattern, $over, $to, $via, $params) =
          ($route->{route}, $route->{over}, $route->{to}, $route->{via}, $route->{params});

        next unless $to;
        my $r = $params ? $routes->route($pattern, %$params) : $routes->route($pattern);

        if ($over) {
            if   (ref $over eq 'HASH') { $r->over(%$over); }
            else                       { $r->over($over); }
        }
        if ($via) {
            $r->via(@$via);
        }
        $r->to(ref $to eq 'HASH' ? %$to : $to);
    }

    # Default "/perldoc" page is Ado/Manual
    my $perldoc = $routes->lookup('perldocmodule');
    if ($perldoc) { $perldoc->to->{module} = 'Ado/Manual'; }

    return $app;
}

sub define_mime_types {
    my ($app) = @_;
    my $mimes = $app->config('types') || {};    #HASHREF
    foreach my $mime (keys %$mimes) {

        # Add new MIME type or redefine any existing
        $app->types->type($mime => $mimes->{$mime});
    }
    return $app;
}

1;


=pod

=encoding utf8

=head1 NAME

Ado - a rapid active commotion (framework for web-projects on Mojolicious)

=head1 SYNOPSIS

  require Mojolicious::Commands;
  Mojolicious::Commands->start_app('Ado');

=head1 DESCRIPTION

L<Ado> is a framework for web-projects based on L<Mojolicious>, written in the
L<Perl programming language|http://www.perl.org/>.  This is the base
application class. Ado C<ISA> L<Mojolicious>.  For a more detailed description
on what Ado is and how to get started with Ado see B<L<Ado::Manual>>.

=head1 ATTRIBUTES

Ado inherits all attributes from Mojolicious and implements the following new
ones.

=head2 ado_home

Returns an instance of L<Mojo::Home> pointing to the base directory where
L<Ado> is installed.

    ~$ ado eval 'say app->ado_home'
    /home/berov/opt/public_dev/Ado

=head2 CODENAME

Returns the current C<CODENAME>.

=head2 home

    #/where/is/your_app/rootdir
    $app->home;

Returns the root directory into which $app is installed.  The guessing order is
the following:

=over

=item 1. If C<$ENV{MOJO_HOME}> is defined, it is honored.

=item 2. The upper directory of the directory in which the starting executable
C<$app-E<gt>moniker> is found, e.g. C<bin/..>.  This may happen to be the same
as L</ado_home>.

=item 3. Fallback to L<Mojo/home>. This is the usual behavior of any L<Mojo>
application.

=back

=head2 sessions

Access the L<Ado::Sessions> instance. Instantiates one of
L<Ado::Sessions::File>, L<Ado::Sessions::Database>
or L<Mojolicious::Sessions> depending on configuration and returns it.



( run in 0.981 second using v1.01-cache-2.11-cpan-39bf76dae61 )