Custom HandlersΒΆ
When requesting a config-instance using
get_config()
it is possible to specify a custom
file-handler using the handler
keyword arg. For example:
from config_resolver import get_config
from config_resolver.handlers.json import JsonHandler
result = get_config('foo', 'bar', handler=JsonHandler)
Each handler has full control over the data type which is returned by
get_config()
. get_config
always returns a
named-tuple with two arguments:
config
: This contains the object returned by thehandler
.meta
: This is a named-tuple which is generated by config_resolver and not modifyable by ahandler
. See The Meta Object.
A handler must be subclassed from
config_resolver.handler.base.Handler
which allows us to provide
good type-hinting.
See the existing handlers in config_resolver.handler
for some
practical examples.