NAME
Minima::Setup - Setup a Minima web application
SYNOPSIS
# app.psgi
use Minima::Setup 'config.pl';
\&Minima::Setup::init;
DESCRIPTION
This package is dedicated to the initial setup of a web application using Minima. It provides the main init
subroutine which runs the app and can be passed (as a reference) as the starting subroutine of a PSGI application. Additionally, it includes prepare
, responsible for loading the configuration file and preparing the main objects.
CONFIG FILE
An optional argument may be optionally passed when use
-ing this module, representing the configuration file. This argument is forwarded to prepare
which can also be called directly. Minima::Setup will attempt to read the file and use it to initialize Minima::App.
By default, the configuration file is assumed to be etc/config.pl. If this file exists and no other location is provided, it will be used. If nothing was passed and no file exists at the default location, the app will be loaded with an empty configuration hash.
SUBROUTINES
init
sub init ($env)
Receives the Plack environment and runs the Minima::App object. A reference to this subroutine can be passed as the starting point of the PSGI application.
prepare
sub prepare ($file = undef)
Reads the provided configuration file, or the default one (see "Config File") and initializes the internal Minima::App object.
test
sub test ()
Creates and returns a Plack::Test object with the current Minima::App. See Minima::Manual::Testing for more on testing.
TESTING
For testing purposes, you may want to have Minima::Setup load the configuration and create a Minima::App. You can access a reference to the created app (after importing the module) with Minima::Setup::app
.
SEE ALSO
AUTHOR
Cesar Tessarin, <cesar@tessarin.com.br>.
Written in September 2024.