.\" 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 "Dancer::Config 3pm" .TH Dancer::Config 3pm "2023-02-10" "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" Dancer::Config \- how to configure Dancer to suit your needs .SH "VERSION" .IX Header "VERSION" version 1.3521 .SH "DESCRIPTION" .IX Header "DESCRIPTION" Dancer::Config handles reading and changing the configuration of your Dancer apps. The documentation for this module aims to describe how to change settings, and which settings are available. .SH "SETTINGS" .IX Header "SETTINGS" You can change a setting with the keyword \fBset\fR, like the following: .PP .Vb 1 \& use Dancer; \& \& # changing default settings \& set port => 8080; \& set content_type => \*(Aqtext/plain\*(Aq; \& set startup_info => 0; .Ve .PP A better way of defining settings exists: using \s-1YAML\s0 file. For this to be possible, you have to install the \s-1YAML\s0 module. If a file named \fBconfig.yml\fR exists in the application directory it will be loaded as a setting group. .PP The same is done for the environment file located in the \fBenvironments\fR directory. .PP To fetch the available configuration values use the \fBconfig\fR keyword that returns a reference to a hash: .PP .Vb 2 \& my $port = config\->{port}; \& my $appdir = config\->{appdir}; .Ve .PP By default, the module \s-1YAML\s0 will be used to parse the configuration files. If desired, it is possible to use \s-1YAML::XS\s0 instead by changing the \s-1YAML\s0 engine configuration in the application code: .PP .Vb 1 \& config\->{engines}{YAML}{module} = \*(AqYAML::XS\*(Aq; .Ve .PP See Dancer::Serializer::YAML for more details. .SH "SUPPORTED SETTINGS" .IX Header "SUPPORTED SETTINGS" .SS "Run mode and listening interface/port" .IX Subsection "Run mode and listening interface/port" \fIserver (string)\fR .IX Subsection "server (string)" .PP The \s-1IP\s0 address that the Dancer app should bind to. Default is 0.0.0.0, i.e. bind to all available interfaces. .PP Can also be set with environment variable \s-1DANCER_SERVER\s0 .PP \fIport (int)\fR .IX Subsection "port (int)" .PP The port Dancer will listen to. .PP Default value is 3000. This setting can be changed on the command-line with the \&\fB\-\-port\fR switch. .PP Can also be set with environment variable \s-1DANCER_PORT\s0 .PP \fIdaemon (boolean)\fR .IX Subsection "daemon (boolean)" .PP If set to true, runs the standalone webserver in the background. This setting can be changed on the command-line with the \fB\-\-daemon\fR flag. .PP Can also be enabled by setting environment variable \s-1DANCER_DAEMON\s0 to a true value. .PP \fIbehind_proxy (boolean)\fR .IX Subsection "behind_proxy (boolean)" .PP If set to true, Dancer 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. This is useful if your application is behind a proxy. .PP It will also cause Dancer::Request\->address to return what Dancer::Request\->forwarded_for_address would return, namely the content of the `HTTP_X_FORWARDED_FOR` env var/header, so that requests will appear to have come from the end user's \s-1IP\s0 and not the proxy's. .PP Because of the above, you should *not* turn this on if your app isn't behind a proxy which will pass this information on appropriately, otherwise a malicious user could supply false information. .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 Can also be set with environment variable \s-1DANCER_CONTENT_TYPE\s0 .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 Dancer in which charset the static files and templates are encoded. .IP "\(bu" 4 If you're using Dancer::Plugin::Database, \s-1UTF\-8\s0 support will automatically be enabled for your database \- see \&\*(L"\s-1AUTOMATIC UTF\-8 SUPPORT\*(R"\s0 in Dancer::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 Can also be set with environment variable \s-1DANCER_CHARSET\s0 .PP \fIdefault_mime_type (string)\fR .IX Subsection "default_mime_type (string)" .PP Dancer's Dancer::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 "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 Dancer applications have an \f(CW\*(C`environments\*(C'\fR folder with specific configuration files for different environments (usually development and production environments). They specify different kinds of error reporting, deployment details, etc. These files are read after the generic \f(CW\*(C`config.yml\*(C'\fR configuration file. .PP The running environment can be set with: .PP .Vb 1 \& set environment => "production"; .Ve .PP Note that this variable is also used as a default value if other values are not defined. .PP Can also be set with environment variable \s-1DANCER_ENVIRONMENT\s0 .PP \fIappdir (directory)\fR .IX Subsection "appdir (directory)" .PP This is the path where your application will live. It's where Dancer will look by default for your config files, templates and static content. .PP It is typically set by \f(CW\*(C`use Dancer\*(C'\fR to use the same directory as your script. .PP Can also be set with environment variable \s-1DANCER_APPDIR\s0 .PP \fIpublic (directory)\fR .IX Subsection "public (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 By default it points to \f(CW$appdir\fR/public. .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 This defaults to \f(CW$appdir\fR/views. .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. Dancer will look for a matching template in the directory \f(CW$views\fR/layouts. .PP Your can override the default layout using the third argument of the \&\f(CW\*(C`template\*(C'\fR keyword. Check \f(CW\*(C`Dancer\*(C'\fR manpage for details. .SS "Logging, debugging and error handling" .IX Subsection "Logging, debugging and error handling" \fIstrict_config (boolean, default: false)\fR .IX Subsection "strict_config (boolean, default: false)" .PP If true, \f(CW\*(C`config\*(C'\fR will return an object instead of a hash reference. See Dancer::Config::Object for more information. .PP \fIglobal_warnings (boolean, default: false)\fR .IX Subsection "global_warnings (boolean, default: false)" .PP If true, \f(CW\*(C`use warnings\*(C'\fR will be in effect for all modules and scripts loaded by your Dancer application. Default is false. .PP Can also be enabled by setting the environment variable \s-1DANCER_WARNINGS\s0 to a true value. .PP \fIstartup_info (boolean)\fR .IX Subsection "startup_info (boolean)" .PP If set to true (the default), prints a banner at server startup with information such as versions and the environment (or \*(L"dancefloor\*(R"). .PP Can also be disabled by setting the environment variable \s-1DANCER_NO_STARTUP_INFO\s0 to a true value. .PP \fIwarnings (boolean)\fR .IX Subsection "warnings (boolean)" .PP If set to true, tells Dancer to consider all warnings as blocking errors. Default is false. .PP \fItraces (boolean)\fR .IX Subsection "traces (boolean)" .PP If set to true, Dancer will display full stack traces when a warning or a die occurs. (Internally sets Carp::Verbose). Default is false. .PP Can also be enabled by setting environment variable \s-1DANCER_TRACES\s0 to a true value. .PP \fIrequire_environment (boolean)\fR .IX Subsection "require_environment (boolean)" .PP If set to true, Dancer will fail during startup if your environment file is missing or can't be read. This is especially useful in production when you have things like memcached settings that need to be set per-environment. Defaults to false. .PP \fIserver_tokens (boolean)\fR .IX Subsection "server_tokens (boolean)" .PP If set to true (the default), Dancer will add an \*(L"X\-Powered-By\*(R" header and also append the Dancer version to the \*(L"Server\*(R" header. .PP Can also be disabled by setting the environment variable \s-1DANCER_NO_SERVER_TOKENS\s0 to a true value. .PP \fIlog_path (string)\fR .IX Subsection "log_path (string)" .PP Folder where the ``file \f(CW\*(C`logger\*(C'\fR'' saves log files. .PP \fIlog_file (string)\fR .IX Subsection "log_file (string)" .PP Name of the file to create when ``file \f(CW\*(C`logger\*(C'\fR'' is active. It defaults to the \f(CW\*(C`environment\*(C'\fR setting contents. .PP \fIlogger (enum)\fR .IX Subsection "logger (enum)" .PP Select which logger to use. For example, to write to log files in \f(CW\*(C`log_path\*(C'\fR: .PP .Vb 1 \& logger: file .Ve .PP Or to direct log messages to the console from which you started your Dancer app in standalone mode, .PP .Vb 1 \& logger: console .Ve .PP Various other logger backends are available on \s-1CPAN,\s0 including Dancer::Logger::Syslog, Dancer::Logger::Log4perl, Dancer::Logger::PSGI (which can, with the aid of Plack middlewares, send log messages to a browser's console window) and others. .PP Can also be set with environment variable \s-1DANCER_LOGGER\s0 .PP \fIlog (enum)\fR .IX Subsection "log (enum)" .PP Tells which log messages should be actually logged. Possible values are \&\fBcore\fR, \fBdebug\fR, \fBwarning\fR or \fBerror\fR. .IP "\fBcore\fR : all messages are logged, including some from Dancer itself" 4 .IX Item "core : all messages are logged, including some from Dancer 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 Dancer 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. .PP \fIshow_errors (boolean)\fR .IX Subsection "show_errors (boolean)" .PP If set to true, Dancer will render a detailed debug screen whenever an error is caught. If set to false, Dancer will render the default error page, using \&\f(CW$public\fR/$error_code.html if it exists 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_errors 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 can use three variables: .IP "\fBtitle\fR" 4 .IX Item "title" The error title. .IP "\fBmessage\fR" 4 .IX Item "message" The error message. .IP "\fBcode\fR" 4 .IX Item "code" The code throwing that error. .SS "Session engine" .IX Subsection "Session engine" \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 Dancer. You must choose a session engine to use them. .PP See Dancer::Session for supported engines and their respective configuration. .PP \fIsession_expires\fR .IX Subsection "session_expires" .PP The session expiry time in seconds, or as e.g. \*(L"2 hours\*(R" (see \&\*(L"expires\*(R" in Dancer::Cookie. By default there is no specific expiry time. .PP \fIsession_name\fR .IX Subsection "session_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 \fIsession_secure\fR .IX Subsection "session_secure" .PP The user's session \s-1ID\s0 is stored in a cookie. If the \f(CW\*(C`session_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 \fIsession_is_http_only\fR .IX Subsection "session_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 its value. .PP \fIsession_domain\fR .IX Subsection "session_domain" .PP Allows you to set the domain property on the cookie, which will override the default. This is useful for setting the session cookie's domain to something like \f(CW\*(C`.domain.com\*(C'\fR so that the same cookie will be applicable and usable across subdomains of a base domain. .PP \fIsession_same_site\fR .IX Subsection "session_same_site" .PP If set, session cookies will have the SameSite attribute set to the specified value to control cross-site request cookie handling. If set, the value must be one of the values described in RFC6265bis \- 'Strict', 'Lax' or 'None'. .ie n .IP """Strict"" \- Cookies will only be sent in a first-party context and not be sent along with requests initiated by third party websites." 4 .el .IP "\f(CWStrict\fR \- Cookies will only be sent in a first-party context and not be sent along with requests initiated by third party websites." 4 .IX Item "Strict - Cookies will only be sent in a first-party context and not be sent along with requests initiated by third party websites." .PD 0 .ie n .IP """Lax"" \- Cookies are allowed to be sent with top-level navigations and will be sent along with \s-1GET\s0 request initiated by third party website. This is the default value in modern browsers." 4 .el .IP "\f(CWLax\fR \- Cookies are allowed to be sent with top-level navigations and will be sent along with \s-1GET\s0 request initiated by third party website. This is the default value in modern browsers." 4 .IX Item "Lax - Cookies are allowed to be sent with top-level navigations and will be sent along with GET request initiated by third party website. This is the default value in modern browsers." .ie n .IP """None"" \- Cookies will be sent in all contexts, i.e sending cross-origin is allowed." 4 .el .IP "\f(CWNone\fR \- Cookies will be sent in all contexts, i.e sending cross-origin is allowed." 4 .IX Item "None - Cookies will be sent in all contexts, i.e sending cross-origin is allowed." .PD .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, Dancer 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, Dancer will look in the views dir for \&\f(CW\*(C`/foo/bar.tt\*(C'\fR. .PP Dancer will honor your \f(CW\*(C`before_template_render\*(C'\fR code, and all default variables. They will be accessible and interpolated on automaticly-served pages. .PP The pages served this way will have \f(CW\*(C`Content\-Type\*(C'\fR set to \f(CW\*(C`text/html\*(C'\fR, so don't use the feature for anything else. .SS "Route caching" .IX Subsection "Route caching" \fIroute_cache (boolean)\fR .IX Subsection "route_cache (boolean)" .PP If true, enables route caching (for quicker route resolution on larger apps \- not caching of responses). See Dancer::Route::Cache for details. Default is false. .PP \fIroute_cache_size_limit (bytes)\fR .IX Subsection "route_cache_size_limit (bytes)" .PP Maximum size of route cache (e.g. 1024, 2M). Defaults to 10M (10MB) \- see Dancer::Route::Cache .PP \fIroute_cache_path_limit (number)\fR .IX Subsection "route_cache_path_limit (number)" .PP Maximum number of routes to cache. Defaults to 600 \- see Dancer::Route::Cache .SS "\s-1DANCER_CONFDIR\s0 and \s-1DANCER_ENVDIR\s0" .IX Subsection "DANCER_CONFDIR and DANCER_ENVDIR" It's possible to set the configuration directory and environment directory using these two environment variables. Setting `DANCER_CONFDIR` will have the same effect as doing .PP .Vb 1 \& set confdir => \*(Aq/path/to/confdir\*(Aq .Ve .PP and setting `DANCER_ENVDIR` will be similar to: .PP .Vb 1 \& set envdir => \*(Aq/path/to/environments\*(Aq .Ve .SH "ENVIRONMENT VARIABLES" .IX Header "ENVIRONMENT VARIABLES" Some settings can be provided via environment variables at runtime, as detailed above; a full list of environment variables you can use follows. .PP \&\s-1DANCER_APPDIR\s0 .PP \&\s-1DANCER_APPHANDLER\s0 a Dancer::Handler::* by default Dancer::Handler::Standalone .PP \&\s-1DANCER_AUTO_RELOAD\s0 .PP \&\s-1DANCER_CHARSET\s0 .PP \&\s-1DANCER_CONFDIR\s0 .PP \&\s-1DANCER_CONTENT_TYPE\s0 .PP \&\s-1DANCER_DAEMON\s0 .PP \&\s-1DANCER_ENVDIR\s0 .PP \&\s-1DANCER_ENVIRONMENT\s0 .PP \&\s-1DANCER_NO_SERVER_TOKENS\s0 .PP \&\s-1DANCER_NO_STARTUP_INFO\s0 .PP \&\s-1DANCER_LOGGER\s0 .PP \&\s-1DANCER_PORT\s0 .PP \&\s-1DANCER_SERVER\s0 .PP \&\s-1DANCER_TRACES\s0 .PP \&\s-1DANCER_WARNINGS\s0 .SH "AUTHOR" .IX Header "AUTHOR" This module has been written by Alexis Sukrieh and others, see the \s-1AUTHORS\s0 file that comes with this distribution for details. .SH "LICENSE" .IX Header "LICENSE" This module is free software and is released under the same terms as Perl itself. .SH "SEE ALSO" .IX Header "SEE ALSO" Dancer .SH "AUTHOR" .IX Header "AUTHOR" Dancer Core Developers .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2010 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.