=encoding utf8

=head1 CUSTOMIZING

Customizing you usage of Minima is quite straightforward once you
understand how it works and a few PSGI concepts. If you haven't yet,
check L<"How it works" in Minima|Minima/"HOW IT WORKS">.

=head1 Setup

The setup process can be completely skipped. If your goal is to create a
custom app, load your configuration hash and create L<Minima::App>
yourself:

F<app.psgi>

    use Minima::App;

    my $app = Minima::App->new(
        environment => $env,
        configuration => $config,
    );

    sub { $app->run }

=head1 Controllers

A controller is where you implement your application’s logic. Its main
role is to return a valid PSGI response.

By default, controllers inherit from L<Minima::Controller>, which
provides convenient lifecycle hooks and helper methods.

However, inheritance is not required. A controller can simply provide
the action methods declared in C<routes.map>. In that case, Minima will
call the methods directly and expect them to return a valid PSGI
response. This makes it easy to write very minimal controllers if you
prefer.

When L<Minima::App> instantiates and calls your controller, it will pass
two named arguments to C<new>:

    app   => $self,
    route => $m,

Depending on your implementation details (whether your controller is a
class, package, or another type of object) you may or may not use these
arguments.

=head2 Arguments

=over 16

=item C<app>

A reference to the L<Minima::App> instance which is initializing your
controller.

=item C<route>

The matched route as returned by L<Minima::Router>.

=back

=head2 Lifecycle Hooks

Controllers may also define optional lifecycle hooks:

=over 16

=item C<before_action ($method)>

Runs before the action is executed. If it returns a PSGI response, the
action itself is skipped and that response is returned immediately.

=item C<after_action ($response)>

Runs after the action has completed. It receives the response returned
by the action, which can be modified in place if needed.

=back

For more details, see L<the run method in Minima::App|Minima::App/run>.

As your controller is called last, remember to return a valid PSGI
response and you're good to go.

=head1 Templating System

If you want to customize how L<Template Toolkit|Template> is used in
L<Minima::View::HTML>, check L<"Configuration" in
Minima::View::HTML|Minima::View::HTML/CONFIGURATION>.

If you don't want to use Template Toolkit at all, just skip
L<Minima::View::HTML>. Your controller logic is solely responsible
for calling it, so feel free to create your own views.

=head1 SEE ALSO

L<Minima>, L<Minima::Manual::FAQ>, L<perlclass>.

=head1 AUTHOR

Cesar Tessarin, <cesar@tessarin.com.br>.

Written in September 2024.
