The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Dancer::Config - setting registry for Dancer

DESCRIPTION

Setting registry for Dancer

SETTINGS

You can change a setting with the keyword set, like the following:

    use Dancer;

    # changing default settings
    set port => 8080;
    set content_type => 'text/plain';
    set access_log => 0;

A better way of defining settings exists: using YAML file. For this to be possible, you have to install the YAML module. If a file named config.yml exists in the application directory, it will be loaded, as a setting group.

The same is done for the environment file located in the environments directory.

SUPPORTED SETTINGS

server (string)

The IP address that the Dancer app should bind to. Default is 0.0.0.0, i.e. bind to all available interfaces.

port (int)

The port Dancer will listen to.

Default value is 3000. This setting can be changed on the command-line with the --port switch.

daemon (boolean)

If set to true, runs the standalone webserver in the background. This setting can be changed on the command-line with the --daemon flag.

content_type (string)

The default content type of outgoing content. Default value is 'text/html'.

charset (string)

This setting does 3 things:

  • It sets the default charset of outgoing content. charset= item will be added to Content-Type response header.

  • It makes Unicode bodies in HTTP responses of text/* types to be encoded to this charset.

  • It also indicates to Dancer in which charset the static files and templates are encoded.

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 application/json Content-Type, you should always encode them by hand.

appdir (directory)

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.

It is typically set by use Dancer to use the same directory as your script.

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.

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.

layout (string)

The name of the layout to use when rendering view. Dancer will look for a matching template in the directory $views/layout.

warnings (boolean)

If set to true, tells Dancer to consider all warnings as blocking errors.

traces (boolean)

If set to true, Dancer will display full stack traces when a warning or a die occurs. (Internally sets Carp::Verbose). Default to false.

log (enum)

Tells which log messages should be actullay logged. Possible values are core, debug, warning or error.

core : all messages are logged, including some from Dancer itself
debug : all messages are logged
warning : only warning and error messages are logged
error : only error messages are logged

show_errors (boolean)

If set to true, Dancer will render a detailed debug screen whenever an error is catched. If set to false, Dancer will render the default error page, using $public/$error_code.html if it exists.

auto_reload (boolean)

Requires Module::Refresh and Clone.

If set to true, Dancer will reload the route handlers whenever the file where they are defined is changed. This is very useful in development environment but should not be enabled in production. Enabling this flag in production yields a major negative effect on performance because of Module::Refresh.

When this flag is set, you don't have to restart your webserver whenever you make a change in a route handler.

Note that Module::Refresh only operates on files in %INC, so if the script your Dancer app is started from changes, even with auto_reload enabled, you will still not see the changes reflected until you start your app.

session (enum)

This setting lets you enable a session engine for your web application. Be default, sessions are disabled in Dancer, you must choose a session engine to use them.

See Dancer::Session for supported engines and their respective configuration.

AUTHOR

This module has been written by Alexis Sukrieh <sukria@cpan.org> and others, see the AUTHORS file that comes with this distribution for details.

LICENSE

This module is free software and is released under the same terms as Perl itself.

SEE ALSO

Dancer