dagolden/dancer2-plugin-auth-tiny — pull request #2 by melo (2013-09-17 03:59:30+00:00)
Title: Move configuration management to _conf_for():

Hi,

Note: this PR is not ready to be merged yet, its work in progress and more of a RFC at this point. It also needs https://github.com/dagolden/dancer2-plugin-auth-tiny/pull/1 for the test suite to work.

I've been tracking a situation on a Dancer2 issue (see https://github.com/PerlDancer/Dancer2/issues/418), and last night I was able to pin down my problem to Auth::Tiny.

On the `_build_login` code, inside the coderef, Tiny calls `plugin_setting()` to setup `$conf` but at that time, it now longer is able to find the DSL object, when under Starman. In fact, it can find it on the standalone server because the `./bin/app.pl` main namespace has a `use Dancer2`, and that's clearly wrong too.

This PR aims to fix that: we move the call to `plugin_setting()` to early, during setup phase, and we cache the configuration per App class name.

I still need to update the test suite to make sure both of this problems are really fixed, but your comments on the general direction of the fix are appreciated.

Thanks,