[Dancer-users] [RFC] Change in prefix / before functionality

Richard Huxton dev at archonet.com
Fri Apr 1 10:21:29 CEST 2011


On 28/03/11 22:38, David Precious wrote:
> On Mon, 2011-03-28 at 20:51 +0100, Simon Wistow wrote:
>> I'd really like to be able to do something like this

>> package MyApp;
>>
>> use MyApp::Secret;
>>
>> prefix 'undef';
>>
>> before sub {
>>    # do something
>> };
>>
>> package MyApp::Secret;
>>
>> prefix '/secret';
>>
>> before sub {
>> 	return unless auth&&  auth->is_admin;
>> }

I've tried to do something similar to Simon too and been disappointed.

I was trying:

load_app 'MyApp::Secret', prefix =>'/secret', before => &admin_only;

I think the surprising thing is the fact that "before" spans packages. 
Within a package, I'm happy with multiple occurrences chaining, but it 
seems wrong for an included module to change global behaviour.

-- 
   Richard Huxton
   Archonet Ltd


More information about the Dancer-users mailing list