There is an ongoing outage on the primary CPAN mirror. It is possible to work around the issue by using MetaCPAN as a mirror.

NAME

Dancer2::Core::Role::ConfigReader - Config reader role for Dancer2 core objects

VERSION

version 2.0.0

DESCRIPTION

This role is implemented by different config readers. A config reader creates the configuration for Dancer2 app. Config can be created by reading configuration files, from environment variables, by fetching it from a cloud service, or any other means.

Default config reader is Dancer2::ConfigReader::Config::Any but user can create his own config reader if he wants to replace or augment the default method of config creation. That method should implement this role.

The implementing module gets the following parameters during creation:

ATTRIBUTES

environment

The name of the environment used, e.g. production, development, staging.

location

The absolute path to the directory where the server started.

default_config

A hash ref which contains the default values.

These arguments are passed when the object is created by Dancer2::Core::App. ConfigReader then passes environment and location forward to every config reader class when it instantiates them. How the config reader applies them, depend on its needs.

Provides a config attribute that - when accessing the first time - feeds itself by finding and parsing configuration files.

Also provides a setting() method which is supposed to be used by externals to read/write config entries.

location

Absolute path to the directory where the server started.

config_location

Gets the location from the configuration. Same as $object->location.

environments_location

Gets the directory where the environment files are stored.

config

Returns the whole configuration.

environments

Returns the name of the environment.

METHODS

read_config

Load the configuration. Whatever source the config comes from, files, env vars, etc.

AUTHOR

Dancer Core Developers

COPYRIGHT AND LICENSE

This software is copyright (c) 2025 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.