/usr/share/perl5/Dancer2/Config.pod is in libdancer2-perl 0.11+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | package Dancer2::Config;
# ABSTRACT: Configure Dancer2 to suit your needs
__END__
=pod
=head1 NAME
Dancer2::Config - Configure Dancer2 to suit your needs
=head1 VERSION
version 0.11
=head1 DESCRIPTION
The Dancer2 configuration (as implemented by L<Dancer2::Core::Role::Config>)
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.
=head1 MANIPULATING SETTINGS VIA CODE
You can change a setting with the keyword C<set>:
use Dancer2;
# changing default settings
set port => 8080;
set content_type => 'text/plain';
set startup_info => 0;
=head1 MANIPULATING SETTINGS VIA CONFIGURATION FILES
There's nothing wrong with using C<set> 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.
=head2 Configuration file path and file names
Dancer2 will first look for the file F<config.ext> (where .ext is the type
of configuration file you are using) 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 (B<not> a
recommended practice!), then this file is all you need.
Next, Dancer2 will look in the F<environments> directory for a configuration
file specific to the platform you are deploying to (F<production.ext> and
F<development.ext>, for example). Any settings in these files that are named
the same as settings in your global configuration file will take precedence
over those settings in the global file. The rest of the settings are merged
and Dancer2 uses the combination of settings from the two files as its
operating configuration.
=head2 Supported configuration file formats
Dancer2 supports any configuration file format that is supported by
L<Config::Any>. At the time of this writing, that includes YAML (.yml and
.yaml), JSON (.jsn and .json), INI (.ini), Apache-style configurations (.cnf
and .conf), XML (.xml), and Perl-style hashes (.pl and .perl).
Make sure you pick the appropriate extension for your configuration file name,
as Dancer2 guesses the type of format based on the file extension.
=head2 Sample configuration files
Note: Not all possibilities are covered here, only the most common options.
If you prefer YAML, a sample YAML based config file might look like this:
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
If JSON is more your thing, your file might look more like this:
{
"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"
}
}
}
}
If you like Apache configuration files, try something similar to:
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
</default>
</DBIC>
</plugins>
INI-style files are deliberately simplistic and not recommended for use in
your Dancer2 applications.
=head1 SUPPORTED SETTINGS
=head2 Run mode and listening interface/port
=head3 server (string)
The IP address that the Dancer2 app should bind to. Default is 0.0.0.0, i.e.
bind to all available interfaces.
=head3 port (int)
The port Dancer2 will listen to.
Default value is 3000. This setting can be changed on the command-line with the
B<--port> switch.
=head3 daemon (boolean)
If set to true, runs the standalone webserver in the background.
This setting can be changed on the command-line with the B<--daemon> flag.
=head3 behind_proxy (boolean)
If set to true, Dancer2 will look to C<X-Forwarded-Protocol> and
C<X-Forwarded-host> when constructing URLs (for example, when using
C<redirect>). This is useful if your application is behind a proxy.
=head2 Content type / character set
=head3 content_type (string)
The default content type of outgoing content.
Default value is 'text/html'.
=head3 charset (string)
This setting has multiple effects:
=over
=item *
It sets the default charset of outgoing content. C<charset=> item will be
added to Content-Type response header.
=item *
It makes Unicode bodies in HTTP responses of C<text/*> types to be encoded to
this charset.
=item *
It also indicates to Dancer2 in which charset the static files and templates are
encoded.
=item *
If you're using L<Dancer2::Plugin::Database>, UTF-8 support will automatically be
enabled for your database - see
L<Dancer2::Plugin::Database/"AUTOMATIC UTF-8 SUPPORT">
=back
Default value is empty which means don't do anything. HTTP responses
without charset will be interpreted as ISO-8859-1 by most clients.
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).
Also, since automatically serialized JSON responses have
C<application/json> Content-Type, you should always encode them by
hand.
=head3 default_mime_type (string)
Dancer2's L<Dancer2::Core::MIME> module uses C<application/data> 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 B<public> folder that do not
have an extension, and are text files, set the C<default_mime_type> to
C<text/plain>.
=head2 File / directory locations
=head3 environment (string)
This is the name of the environment that should be used. Standard
Dancer2 applications have a C<environments> 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 C<config.yml> configuration file.
The running environment can be set with:
set environment => "production";
Note that this variable is also used as a default value if other
values are not defined.
=head3 appdir (directory)
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.
It is typically set by C<use Dancer2> to use the same directory as your
script.
=head3 public (directory)
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.
By default, it points to $appdir/public.
=head3 views (directory)
This is the directory where your templates and layouts live. It's the
"view" part of MVC (model, view, controller).
This defaults to $appdir/views.
=head2 Templating & layouts
=head3 template
Allows you to configure which template engine should be used. For instance, to
use Template Toolkit, add the following to C<config.yml>:
template: template_toolkit
=head3 layout (string)
The name of the layout to use when rendering view. Dancer2 will look for
a matching template in the directory $views/layout.
Your can override the default layout using the third argument of the
C<template> keyword. Check C<Dancer2> manpage for details.
=head2 Logging, debugging and error handling
=head3 strict_config (boolean, default: false)
If true, C<config> will return an object instead of a hash reference. See
L<Dancer2::Config::Object> for more information.
=head3 startup_info (boolean)
If set to true, prints a banner at the server start with information such as
versions and the environment (or "dancefloor").
Conforms to the environment variable C<DANCER_STARTUP_INFO>.
=head3 warnings (boolean)
If set to true, tells Dancer2 to consider all warnings as blocking errors.
=head3 traces (boolean)
If set to true, Dancer2 will display full stack traces when a warning or a die
occurs. (Internally sets Carp::Verbose). Default to false.
=head3 server_tokens (boolean)
If set to true, Dancer2 will add an "X-Powered-By" header and also append
the Dancer2 version to the "Server" header. Default to true.
You can also use the environment variable C<DANCER_SERVER_TOKENS>.
=head3 logger (enum)
Select which logger to use. For example, to write to log files with
L<Dancer2::Logger::File>:
logger: File
Or to direct log messages to the console from which you started your Dancer2 app
with L<Dancer2::Logger::Console>:
logger: Console
Loggers are configured with a corresponding L</Logger engine> section, as
shown below.
=head3 session (enum)
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.
Sessions are configured with a corresponding L</Session engine> section, as
shown below.
=head3 show_errors (boolean)
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
$public/$error_code.html if it exists or the template specified by the
C<error_template> setting.
The error screen attempts to sanitise sensitive looking information (passwords /
card numbers in the request, etc) but you still should not have show_errors
enabled whilst in production, as there is still a risk of divulging details.
=head3 error_template (template path)
This setting lets you specify a template to be used in case of runtime
error. At the present moment the template can use three variables:
=over 4
=item B<title>
The error title.
=item B<message>
The error message.
=item B<code>
The code throwing that error.
=back
=head2 Logger engine
The logger must be configured in a separate C<engines> section, like so:
logger: Console
engines:
logger:
Console:
log_level: core
All loggers support the configuration options below. See documentation
for a particular logger for other supported options.
=head3 log_level
This option tells which log messages should be actually
logged. Possible values are B<core>, B<info>, B<debug>, B<warning> or B<error>.
=over 4
=item B<core> : all messages are logged, including some from Dancer2 itself
=item B<debug> : all messages are logged
=item B<info> : only info, warning and error messages are logged
=item B<warning> : only warning and error messages are logged
=item B<error> : only error messages are logged
=back
During development, you'll probably want to use C<debug> to see your own debug
messages, and C<core> if you need to see what Dancer2 is doing. In production,
you'll likely want C<error> or C<warning> only, for less-chatty logs.
=head2 Session engine
The session engine is configured in the C<engines> section.
session: Simple
engines:
session:
Simple:
cookie_name: dance.set
cookie_duration: '24 hours'
is_secure: 1
is_http_only: 1
See L<Dancer2::Core::Role::SessionFactory> for more detailed documentation
for these options, or the particular session engine for other supported options.
=head3 cookie_name
The name of the cookie to store the session ID in. Defaults to
C<dancer.session>. This can be overridden by certain session engines.
=head3 cookie_domain
The domain of the cookie. By default there is no domain defined for the cookie.
=head3 cookie_path
The path of the cookie. By default there is no path defined for the cookie.
=head3 cookie_duration
The session expiry time in seconds, or as e.g. "2 hours" (see
L<Dancer2::Core::Cookie/expires>. By default, there is no specific expiry
time.
=head3 is_secure
The user's session ID is stored in a cookie. If the C<is_secure> setting
is set to a true value, the cookie will be marked as secure, meaning it should
only be sent over HTTPS connections.
=head3 is_http_only
This setting defaults to 1 and instructs the session cookie to be
created with the C<HttpOnly> option active, meaning that JavaScript
will not be able to access to its value.
=head2 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.
With C<auto_page> 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.
Simply enable auto_page in your config:
auto_page: 1
Then, if you request C</foo/bar>, Dancer2 will look in the views dir for
C</foo/bar.tt>.
Dancer2 will honor your C<before_template_render> code, and all default
variables. They will be accessible and interpolated on automatic
served pages.
=head2 DANCER_CONFDIR and DANCER_ENVDIR
It's possible to set the configuration directory and environment directory using this two
environment variables. Setting B<DANCER_CONFDIR> will have the same effect as doing
set confdir => '/path/to/confdir'
and setting B<DANCER_ENVDIR> will be similar to:
set envdir => '/path/to/environments'
=head1 SEE ALSO
L<Dancer2>
=head1 AUTHOR
Dancer Core Developers
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Alexis Sukrieh.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|