.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Dancer2::Config 3pm"
.TH Dancer2::Config 3pm "2023-12-15" "perl v5.36.0" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
Dancer2::Config \- Configure Dancer2 to suit your needs
.SH "VERSION"
.IX Header "VERSION"
version 1.1.0
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
The Dancer2 configuration (as implemented by
Dancer2::Core::Role::ConfigReader) handles reading and changing the
configuration of your Dancer2 apps. This document describes how to
manipulate Dancer2's configuration settings (through code or by file), and
to document the various settings that are available in Dancer2.
.SH "MANIPULATING SETTINGS VIA CODE"
.IX Header "MANIPULATING SETTINGS VIA CODE"
You can change a setting with the keyword \f(CW\*(C`set\*(C'\fR:
.PP
.Vb 1
\& use Dancer2;
\&
\& # changing default settings
\& set port => 8080;
\& set content_type => \*(Aqtext/plain\*(Aq;
\& set startup_info => 0;
.Ve
.SH "MANIPULATING SETTINGS VIA CONFIGURATION FILES"
.IX Header "MANIPULATING SETTINGS VIA CONFIGURATION FILES"
There's nothing wrong with using \f(CW\*(C`set\*(C'\fR to configure your application. In
fact you might have some great reasons for doing so. For greater
flexibility, ease of deployment, etc., you should also consider extracting
those settings into a configuration file.
.SS "Configuration file path and file names"
.IX Subsection "Configuration file path and file names"
Dancer2 will first look for the file \fIconfig.EXT\fR (where \fI\s-1EXT\s0\fR is the
type of configuration file you are using; e.g. \fIini\fR or \fIjson\fR or
\&\fIyml\fR) in the root directory of your application. This is considered
your global Dancer2 config file. If you do not care to have separate
settings for production and development environments (\fBnot\fR a
recommended practice!), then this file is all you need.
.PP
Next, Dancer2 will look for a file called \fIconfig_local.EXT\fR. This file
is typically useful for deployment-specific configuration that should
not be checked into source control. For instance, database credentials
could be stored in this file. Any settings in this file are merged into
the existing configuration such that those with the same name in your
local configuration file will take precedence over those settings in
the global file.
.PP
Next, Dancer2 will look in the \fIenvironments\fR directory for a configuration
file specific to the platform you are deploying to (\fIproduction.EXT\fR or
\&\fIdevelopment.EXT\fR, for example). Again, the configuration from the environment
is merged with the existing configuration with the deployment config taking
precedence.
.PP
Finally, Dancer2 will look in the \fIenvironments\fR directory for a
local configuration for the specific platform you are deploying to
(e.g. \fIproduction_local.EXT\fR or \fIdevelopment_local.EXT\fR)
The configuration in this file is merged as before.
.PP
Much like \fIconfig_local.EXT\fR, this file would be useful for environment\-
specific configuration that would not be checked into source control.
For instance, when developing an application that talks to multiple services,
each developer could have their own URLs to those services stored within
their \fIenvironments/development_local.yaml\fR file.
.PP
Note, if there is no \fIconfig.EXT\fR, Dancer2 will not look for a
\&\fIconfig_local.EXT\fR. The same is true for the local environment
configuration.
.SS "Supported configuration file formats"
.IX Subsection "Supported configuration file formats"
Dancer2 supports any configuration file format that is supported by
Config::Any. At the time of this writing, that includes \s-1YAML\s0 (.yml and
\&.yaml), \s-1JSON\s0 (.jsn and .json), \s-1INI\s0 (.ini), Apache-style configurations (.cnf
and .conf), \s-1XML\s0 (.xml), and Perl-style hashes (.pl and .perl).
.PP
Dancer2 iterates over these file extensions in the order provided by
Config::Any and loads any config files that it finds with later
configuration information overriding earlier config information. To
restrict which file extension Dancer2 looks for, you may set the
\&\f(CW\*(C`DANCER_CONFIG_EXT\*(C'\fR envinroment variable to a specific extension and
Dancer2 will only look for config files with that extension.
.PP
Make sure you pick the appropriate extension for your configuration file
name, as Dancer2 guesses the type of format based on the file extension.
.SS "Sample configuration files"
.IX Subsection "Sample configuration files"
Note: Not all possibilities are covered here, only the most common options.
.PP
If you prefer \s-1YAML,\s0 a sample \s-1YAML\s0 based config file might look like this:
.PP
.Vb 3
\& appname: "Hello"
\& charset: "UTF\-8"
\& auto_page: 1
\&
\& session: "YAML"
\& serializer: "JSON"
\&
\& plugins:
\& DBIC:
\& default:
\& dsn: dbi:SQLite:db/mydata.db
\& schema_class: Hello::Schema
.Ve
.PP
If \s-1JSON\s0 is more your thing, your file might look more like this:
.PP
.Vb 10
\& {
\& "appname": "Hello",
\& "charset": "UTF\-8",
\& "auto_page": "1",
\& "session": "YAML",
\& "serializer": "JSON",
\& "plugins": {
\& "DBIC": {
\& "default": {
\& "dsn": "dbi:SQLite:db/mydata.db",
\& "schema_class": "Hello::Schema"
\& }
\& }
\& }
\& }
.Ve
.PP
If you like Apache configuration files, try something similar to:
.PP
.Vb 10
\& appname = Hello
\& charset = UTF\-8
\& auto_page = 1
\& session = YAML
\& serializer = JSON
\&
\&
\&
\& dsn = dbi =SQLite =db/mydata.db
\& schema_class = Hello = =Schema
\&
\&
\&
.Ve
.PP
INI-style files are deliberately simplistic and not recommended for use in
your Dancer2 applications.
.SH "SUPPORTED SETTINGS"
.IX Header "SUPPORTED SETTINGS"
.SS "Run mode and listening interface/port"
.IX Subsection "Run mode and listening interface/port"
\fIhost (string)\fR
.IX Subsection "host (string)"
.PP
The \s-1IP\s0 address that the Dancer2 app should bind to. Default is 0.0.0.0,
i.e. bind to all available interfaces.
.PP
\fIport (int)\fR
.IX Subsection "port (int)"
.PP
The port Dancer2 will listen to.
.PP
Default value is 3000. This setting can be changed on the command-line with
the \fB\-\-port\fR switch.
.PP
\fIbehind_proxy (boolean)\fR
.IX Subsection "behind_proxy (boolean)"
.PP
If set to true, Dancer2 will look to \f(CW\*(C`X\-Forwarded\-Protocol\*(C'\fR and
\&\f(CW\*(C`X\-Forwarded\-host\*(C'\fR when constructing URLs (for example, when using \f(CW\*(C`redirect\*(C'\fR
or \f(CW\*(C`host\*(C'\fR). This is useful if your application is behind a proxy.
.PP
\&\fBNote\fR: If either of these are missing, the values of the proxy server will be
used instead. For example, if the client sends a \s-1HTTP/1.0\s0 request to a proxy
that is hosted locally, then \f(CW\*(C`host\*(C'\fR will return the value \*(L"localhost\*(R". In a
similar vein, if the client makes a secure connection to the proxy, but the
proxy does not pass \f(CW\*(C`X\-Forwarded\-Protocol\*(C'\fR, then \f(CW\*(C`base\*(C'\fR will return
\&\*(L"http://...\*(R". For these reasons, it is recommended that the values are
hard-configured in the proxy if possible. For Apache this would be:
.PP
.Vb 2
\& RequestHeader set X_FORWARDED_PROTO "https"
\& RequestHeader set X_FORWARDED_HOST "www.example.com"
.Ve
.PP
\fIno_default_middleware (boolean)\fR
.IX Subsection "no_default_middleware (boolean)"
.PP
If set to true, your Dancer2 application will \fB\s-1NOT\s0\fR be wrapped with the default
\&\s-1PSGI\s0 middleware. The default middleware wrappers are:
.IP "\(bu" 4
Plack::Middleware::FixMissingBodyInRedirect
.IP "\(bu" 4
Plack::Middleware::Head
.SS "Content type / character set"
.IX Subsection "Content type / character set"
\fIcontent_type (string)\fR
.IX Subsection "content_type (string)"
.PP
The default content type of outgoing content. Default value is 'text/html'.
.PP
\fIcharset (string)\fR
.IX Subsection "charset (string)"
.PP
This setting has multiple effects:
.IP "\(bu" 4
It sets the default charset of outgoing content. \f(CW\*(C`charset=\*(C'\fR item will be
added to Content-Type response header.
.IP "\(bu" 4
It makes Unicode bodies in \s-1HTTP\s0 responses of \f(CW\*(C`text/*\*(C'\fR types to be encoded
to this charset.
.IP "\(bu" 4
It also indicates to Dancer2 in which charset the static files and templates
are encoded.
.IP "\(bu" 4
If you're using Dancer2::Plugin::Database, \s-1UTF\-8\s0 support will
automatically be enabled for your database \- see
\&\*(L"\s-1AUTOMATIC UTF\-8 SUPPORT\*(R"\s0 in Dancer2::Plugin::Database
.PP
Default value is empty which means don't do anything. \s-1HTTP\s0 responses without
charset will be interpreted as \s-1ISO\-8859\-1\s0 by most clients.
.PP
You can cancel any charset processing by specifying your own charset in
Content-Type header or by ensuring that response body leaves your handler
without Unicode flag set (by encoding it into some 8bit charset, for
example).
.PP
Also, since automatically serialized \s-1JSON\s0 responses have \f(CW\*(C`application/json\*(C'\fR
Content-Type, you should always encode them by hand.
.PP
\fIdefault_mime_type (string)\fR
.IX Subsection "default_mime_type (string)"
.PP
Dancer2's Dancer2::Core::MIME module uses \f(CW\*(C`application/data\*(C'\fR as a
default mime type. This setting lets the user change it. For example, if you
have a lot of files being served in the \fBpublic\fR folder that do not have an
extension, and are text files, set the \f(CW\*(C`default_mime_type\*(C'\fR to
\&\f(CW\*(C`text/plain\*(C'\fR.
.SS "Serializing responses"
.IX Subsection "Serializing responses"
\fIserializer (string)\fR
.IX Subsection "serializer (string)"
.PP
When writing a webservice, data serialization/deserialization is a common
issue to deal with. Dancer2 can automatically handle that for you, via a
serializer.
.PP
\fIAvailable serializer engines\fR
.IX Subsection "Available serializer engines"
.PP
The following serializers are available, be aware they dynamically depend on
Perl modules you may not have on your system.
.IP "\(bu" 4
\&\fB\s-1JSON\s0\fR
.Sp
Requires \s-1JSON\s0.
.IP "\(bu" 4
\&\fB\s-1YAML\s0\fR
.Sp
Requires \s-1YAML\s0,
.IP "\(bu" 4
\&\fB\s-1XML\s0\fR
.Sp
Requires XML::Simple.
.IP "\(bu" 4
\&\fBMutable\fR
.Sp
Will try to find the appropriate serializer using the \fBContent-Type\fR and
\&\fBAccept-type\fR header of the request.
.SS "Serializer engine"
.IX Subsection "Serializer engine"
The serializer can be configured in a separate \f(CW\*(C`engines\*(C'\fR section, like so:
.PP
.Vb 1
\& serializer: "JSON"
\&
\& engines:
\& serializer:
\& JSON:
\& pretty: 1
.Ve
.PP
See documentation for a particular serializer for supported options.
.SS "File / directory locations"
.IX Subsection "File / directory locations"
\fIenvironment (string)\fR
.IX Subsection "environment (string)"
.PP
This is the name of the environment that should be used. Standard Dancer2
applications have a \f(CW\*(C`environments\*(C'\fR folder with specific configuration files
for different environments (usually development and production
environments). They specify different kind of error reporting, deployment
details, etc. These files are read after the generic \f(CW\*(C`config.yml\*(C'\fR
configuration file.
.PP
\fIappdir (directory)\fR
.IX Subsection "appdir (directory)"
.PP
This is the path where your application will live. It's where Dancer2 will
look by default for your config files, templates and static content.
.PP
It is typically set by \f(CW\*(C`use Dancer2\*(C'\fR to use the same directory as your
script.
.PP
\fIpublic_dir (directory)\fR
.IX Subsection "public_dir (directory)"
.PP
This is the directory, where static files are stored. Any existing file in
that directory will be served as a static file, before matching any route.
.PP
See also \fBstatic_handler\fR.
.PP
Default: \fB\f(CB\*(C`$appdir/public\*(C'\fB\fR.
.PP
\fIstatic_handler (boolean)\fR
.IX Subsection "static_handler (boolean)"
.PP
This setting have to be declared and set to true if you modify standard
\&\f(CW\*(C`public_dir\*(C'\fR location.
.PP
Default: true if \f(CW$ENV{DANCER_PUBLIC}\fR is set or \f(CW\*(C`public_dir\*(C'\fR is set to
\&\fB\f(CB\*(C`$appdir/public\*(C'\fB\fR.
.PP
\fIviews (directory)\fR
.IX Subsection "views (directory)"
.PP
This is the directory where your templates and layouts live. It's the
\&\*(L"view\*(R" part of \s-1MVC\s0 (model, view, controller).
.PP
Default: \fB\f(CB\*(C`$appdir/views\*(C'\fB\fR.
.SS "Templating & layouts"
.IX Subsection "Templating & layouts"
\fItemplate\fR
.IX Subsection "template"
.PP
Allows you to configure which template engine should be used. For instance,
to use Template Toolkit, add the following to \f(CW\*(C`config.yml\*(C'\fR:
.PP
.Vb 1
\& template: template_toolkit
.Ve
.PP
\fIlayout (string)\fR
.IX Subsection "layout (string)"
.PP
The name of the layout to use when rendering view. Dancer2 will look for a
matching template in the directory \f(CW\*(C`$views/layouts\*(C'\fR.
.PP
Your can override the default layout using the third argument of the
\&\f(CW\*(C`template\*(C'\fR keyword. Check \f(CW\*(C`Dancer2\*(C'\fR manpage for details.
.PP
\fIlayout_dir (string)\fR
.IX Subsection "layout_dir (string)"
.PP
A relative path where the layouts reside inside the \f(CW\*(C`views\*(C'\fR directory.
.PP
.Vb 1
\& layout_dir: actual_layouts
.Ve
.PP
Default: \fBlayouts\fR.
.SS "Logging, debugging and error handling"
.IX Subsection "Logging, debugging and error handling"
\fIstartup_info (boolean)\fR
.IX Subsection "startup_info (boolean)"
.PP
If set to true, prints a banner at the server start with information such as
versions and the environment (or \*(L"dancefloor\*(R").
.PP
Conforms to the environment variable \f(CW\*(C`DANCER_STARTUP_INFO\*(C'\fR.
.PP
\fItraces (boolean)\fR
.IX Subsection "traces (boolean)"
.PP
If set to true, Dancer2 will display full stack traces when a warning or a
die occurs. (Internally sets Carp::Verbose). Default to false.
.PP
\fIno_server_tokens (boolean)\fR
.IX Subsection "no_server_tokens (boolean)"
.PP
If set to true, Dancer2 will \fBnot\fR add an \*(L"X\-Powered-By\*(R" header and also append
the Dancer2 version to the \*(L"Server\*(R" header. Default to false \- adding.
.PP
You can also use the environment variable \f(CW\*(C`DANCER_NO_SERVER_TOKENS\*(C'\fR.
.PP
\fIlogger (enum)\fR
.IX Subsection "logger (enum)"
.PP
Select which logger to use. For example, to write to log files with
Dancer2::Logger::File:
.PP
.Vb 1
\& logger: File
.Ve
.PP
Or to direct log messages to the console from which you started your Dancer2
app with Dancer2::Logger::Console:
.PP
.Vb 1
\& logger: Console
.Ve
.PP
Loggers are configured with a corresponding \*(L"Logger engine\*(R" section, as
shown below.
.PP
\fIsession (enum)\fR
.IX Subsection "session (enum)"
.PP
This setting lets you enable a session engine for your web application. By
default, sessions are disabled in Dancer2, you must choose a session engine
to use them.
.PP
Sessions are configured with a corresponding \*(L"Session engine\*(R" section, as
shown below.
.PP
\fIshow_errors (boolean)\fR
.IX Subsection "show_errors (boolean)"
.PP
Deprecated configuration.
.PP
Use \f(CW\*(C`show_stacktrace\*(C'\fR described below instead.
.PP
\fIshow_stacktrace (boolean)\fR
.IX Subsection "show_stacktrace (boolean)"
.PP
If set to true, Dancer2 will render a detailed debug screen whenever an
error is caught. If set to false, Dancer2 will render the default error
page, using \f(CW\*(C`$public/$error_code.html\*(C'\fR if it exists, \f(CW\*(C`$views/$error_code.tt\*(C'\fR or the template specified
by the \f(CW\*(C`error_template\*(C'\fR setting.
.PP
The error screen attempts to sanitise sensitive looking information
(passwords / card numbers in the request, etc) but you still should not have
show_stacktrace enabled whilst in production, as there is still a risk of
divulging details.
.PP
\fIerror_template (template path)\fR
.IX Subsection "error_template (template path)"
.PP
This setting lets you specify a template to be used in case of runtime
error. At the present moment the template (as well as \f(CW\*(C`$views/$error_code.tt\*(C'\fR templates) can use four variables:
.IP "\fBtitle\fR" 4
.IX Item "title"
The error title.
.IP "\fBcontent\fR" 4
.IX Item "content"
The error specific content (if any).
.IP "\fBstatus\fR" 4
.IX Item "status"
The \s-1HTTP\s0 status code throwing that error.
.IP "\fBexception\fR" 4
.IX Item "exception"
The stringified exception (e.g. $@) if any.
.PP
Keep in mind that 'content' and 'exception' can vary depending on the problem.
.PP
For example:
.PP
A 404 has an empty 'exception' and 'content' contains the \s-1URI\s0 that was not found. Unless you do the 404 yourself via \f(CW\*(C`send_error("You chose ... poorly!", 404);\*(C'\fR, then 'content' is 'You chose ... poorly!'.
.PP
A 500 because of, say, dividing 0 by 0 will have an empty 'content' and 'exception like 'Illegal division by zero at ...'.
.PP
A 401 from \f(CW\*(C`send_error("You can not know the secret until you sign in grasshopper!", 401);\*(C'\fR will have an empty 'exception' and 'content' will contain 'You can not know the secret until you sign in grasshopper!'.
.SS "Logger engine"
.IX Subsection "Logger engine"
The logger must be configured in a separate \f(CW\*(C`engines\*(C'\fR section, like so:
.PP
.Vb 1
\& logger: Console
\&
\& engines:
\& logger:
\& Console:
\& log_level: core
.Ve
.PP
All loggers support the configuration options below. See documentation for
a particular logger for other supported options.
.PP
\fIlog_level\fR
.IX Subsection "log_level"
.PP
This option tells which log messages should be actually logged. Possible
values are \fBcore\fR, \fBinfo\fR, \fBdebug\fR, \fBwarning\fR or \fBerror\fR.
.IP "\fBcore\fR : all messages are logged, including some from Dancer2 itself" 4
.IX Item "core : all messages are logged, including some from Dancer2 itself"
.PD 0
.IP "\fBdebug\fR : all messages are logged" 4
.IX Item "debug : all messages are logged"
.IP "\fBinfo\fR : only info, warning and error messages are logged" 4
.IX Item "info : only info, warning and error messages are logged"
.IP "\fBwarning\fR : only warning and error messages are logged" 4
.IX Item "warning : only warning and error messages are logged"
.IP "\fBerror\fR : only error messages are logged" 4
.IX Item "error : only error messages are logged"
.PD
.PP
During development, you'll probably want to use \f(CW\*(C`debug\*(C'\fR to see your own
debug messages, and \f(CW\*(C`core\*(C'\fR if you need to see what Dancer2 is doing. In
production, you'll likely want \f(CW\*(C`error\*(C'\fR or \f(CW\*(C`warning\*(C'\fR only, for less-chatty
logs.
.SS "Session engine"
.IX Subsection "Session engine"
The session engine is configured in the \f(CW\*(C`engines\*(C'\fR section.
.PP
.Vb 1
\& session: Simple
\&
\& engines:
\& session:
\& Simple:
\& cookie_name: dance.set
\& cookie_duration: \*(Aq24 hours\*(Aq
\& cookie_same_site: Lax
\& is_secure: 1
\& is_http_only: 1
.Ve
.PP
See Dancer2::Core::Role::SessionFactory for more detailed documentation
for these options, or the particular session engine for other supported
options.
.PP
\fIcookie_name\fR
.IX Subsection "cookie_name"
.PP
The name of the cookie to store the session \s-1ID\s0 in. Defaults to
\&\f(CW\*(C`dancer.session\*(C'\fR. This can be overridden by certain session engines.
.PP
\fIcookie_domain\fR
.IX Subsection "cookie_domain"
.PP
The domain of the cookie. By default there is no domain defined for the
cookie.
.PP
\fIcookie_path\fR
.IX Subsection "cookie_path"
.PP
The path of the cookie. By default there is no path defined for the cookie.
.PP
\fIcookie_duration\fR
.IX Subsection "cookie_duration"
.PP
The session expiry time in seconds, or as e.g. \*(L"2 hours\*(R" (see
\&\*(L"expires\*(R" in Dancer2::Core::Cookie. By default, there is no specific expiry
time.
.PP
\fIcookie_same_site\fR
.IX Subsection "cookie_same_site"
.PP
Restricts the session cookie to a first-party or same-site context. Valid
values are \f(CW\*(C`Strict\*(C'\fR, \f(CW\*(C`Lax\*(C'\fR, or \f(CW\*(C`None\*(C'\fR.
.PP
Refer to
RFC6265bis
for further details regarding same-site context.
.PP
\fIis_secure\fR
.IX Subsection "is_secure"
.PP
The user's session \s-1ID\s0 is stored in a cookie. If the \f(CW\*(C`is_secure\*(C'\fR setting is
set to a true value, the cookie will be marked as secure, meaning it should
only be sent over \s-1HTTPS\s0 connections.
.PP
\fIis_http_only\fR
.IX Subsection "is_http_only"
.PP
This setting defaults to 1 and instructs the session cookie to be created
with the \f(CW\*(C`HttpOnly\*(C'\fR option active, meaning that JavaScript will not be able
to access to its value.
.SS "auto_page (boolean)"
.IX Subsection "auto_page (boolean)"
For simple pages where you're not doing anything dynamic, but still want to
use the template engine to provide headers etc, you can use the auto_page
feature to avoid the need to create a route for each page.
.PP
With \f(CW\*(C`auto_page\*(C'\fR enabled, if the requested path does not match any specific
route, Dancer2 will check in the views directory for a matching template,
and use it to satisfy the request if found.
.PP
Simply enable auto_page in your config:
.PP
.Vb 1
\& auto_page: 1
.Ve
.PP
Then, if you request \f(CW\*(C`/foo/bar\*(C'\fR, Dancer2 will look in the views dir for
\&\f(CW\*(C`/foo/bar.tt\*(C'\fR.
.PP
Dancer2 will honor your \f(CW\*(C`before_template_render\*(C'\fR code, and all default
variables. They will be accessible and interpolated on automatic served
pages.
.SS "dsl_class"
.IX Subsection "dsl_class"
For complex applications that require extended \s-1DSL\s0 keywords or other
functionality the \s-1DSL\s0 class used can be specified at import time or in the
config settings.
.PP
.Vb 1
\& dsl_class: \*(AqMy::DSL\*(Aq
.Ve
.PP
This is the same as specifying
.PP
.Vb 1
\& use Dancer2 dsl => \*(AqMy::DSL\*(Aq
.Ve
.PP
in your module. dsl_class defaults to Dancer2::Core::DSL if not specified
.SS "Environment variables"
.IX Subsection "Environment variables"
\fI\s-1DANCER_CONFDIR\s0\fR
.IX Subsection "DANCER_CONFDIR"
.PP
Sets the configuration directory.
.PP
This correlates to the \f(CW\*(C`confdir\*(C'\fR config option.
.PP
\fI\s-1DANCER_ENVDIR\s0\fR
.IX Subsection "DANCER_ENVDIR"
.PP
Sets the environment directory.
.PP
This correlates to the \f(CW\*(C`envdir\*(C'\fR config option.
.PP
\fI\s-1PLACK_ENV\s0\fR
.IX Subsection "PLACK_ENV"
.PP
Sets the given environment. This can be overridden by
\&\f(CW\*(C`DANCER_ENVIRONMENT\*(C'\fR.
.PP
\fI\s-1DANCER_ENVIRONMENT\s0\fR
.IX Subsection "DANCER_ENVIRONMENT"
.PP
Sets the given environment. This takes higher precedence over
\&\f(CW\*(C`PLACK_ENV\*(C'\fR.
.PP
If neither \f(CW\*(C`PLACK_ENV\*(C'\fR or \f(CW\*(C`DANCER_ENVIRONMENT\*(C'\fR is set, the environment
defaults to \fBdevelopment\fR.
.PP
\fI\s-1DANCER_APPHANDLER\s0\fR
.IX Subsection "DANCER_APPHANDLER"
.PP
The \f(CW\*(C`DANCER_APPHANDLER\*(C'\fR configuration controls what the \f(CW\*(C`dance\*(C'\fR keyword
does.
.PP
If is set to \f(CW\*(C`PSGI\*(C'\fR (which will automatically be set if \f(CW\*(C`PLACK_ENV\*(C'\fR is
set), \f(CW\*(C`dance\*(C'\fR will return the \s-1PSGI\s0 application coderef.
.PP
Otherwise (which is the default is \- \f(CW\*(C`Standalone\*(C'\fR), it runs the Plack
standalone server with the application.
.PP
\fI\s-1DANCER_PORT\s0\fR
.IX Subsection "DANCER_PORT"
.PP
Sets the port which will be used by the development server (if not run
by plackup).
.PP
\fI\s-1DANCER_SERVER\s0\fR
.IX Subsection "DANCER_SERVER"
.PP
Sets the host the development server will be used by the development
server (if not run by plackup).
.PP
\&\fBNote\fR: this might change in the future.
.PP
\fI\s-1DANCER_STARTUP_INFO\s0\fR
.IX Subsection "DANCER_STARTUP_INFO"
.PP
Controls whether to display start up info.
.PP
\fI\s-1DANCER_NO_SERVER_TOKENS\s0\fR
.IX Subsection "DANCER_NO_SERVER_TOKENS"
.PP
Controls whether to display the server tokens.
.PP
\fI\s-1DANCER_PUBLIC\s0\fR
.IX Subsection "DANCER_PUBLIC"
.PP
Sets the public directory location.
.PP
\fI\s-1DANCER_TRACES\s0\fR
.IX Subsection "DANCER_TRACES"
.PP
Sets the tracing flag which sets Carp's \f(CW$Verbose\fR flag.
.PP
\fI\s-1DANCER_VIEWS\s0\fR
.IX Subsection "DANCER_VIEWS"
.PP
Sets the views (templates) directory.
.PP
\fI\s-1DANCER_LOGGER\s0\fR
.IX Subsection "DANCER_LOGGER"
.PP
Sets the logger engine.
.PP
\fI\s-1DANCER_CHARSET\s0\fR
.IX Subsection "DANCER_CHARSET"
.PP
Sets the default charset.
.PP
\fI\s-1DANCER_CONTENT_TYPE\s0\fR
.IX Subsection "DANCER_CONTENT_TYPE"
.PP
Sets the default content type.
.PP
If not set, defaults to \fBtext/html\fR.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
Dancer2
.SH "AUTHOR"
.IX Header "AUTHOR"
Dancer Core Developers
.SH "COPYRIGHT AND LICENSE"
.IX Header "COPYRIGHT AND LICENSE"
This software is copyright (c) 2023 by Alexis Sukrieh.
.PP
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.