<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello. New Dancer2 user here. I am having problems with the scope
of a 'hook before' while using 'prefix'. I am not sure if I am
doing something dumb or if this is simply not possible or something
else is going on.<br>
<br>
Using the prefix example from the Cookbook I have two modules<br>
<br>
<font face="Courier New, Courier, monospace">package myapp;<br>
use Dancer2;<br>
use myapp::admin;<br>
<br>
prefix undef;<br>
get '/' => sub { return 'main ' . dancer_version };<br>
1;</font><br>
<br>
And<br>
<br>
<font face="Courier New, Courier, monospace">package myapp::admin;<br>
use Dancer2 appname => 'myapp';<br>
<br>
prefix '/admin';<br>
<br>
hook 'before' => sub {<br>
if (dancer_app->environment ne 'rick') {<br>
return halt;<br>
}<br>
};<br>
<br>
get '/' => sub { return 'admin' };<br>
1;</font><br>
<br>
As expected when running with environment 'rick' then the following
output is produced:<br>
<br>
<font face="Courier New, Courier, monospace">/ ==> main
0.166001<br>
/admin/ ==> admin<br>
</font><br>
But, unexpectedly to me, using the default 'development' environment
has the app just halting as it, I presume, hits the 'hook
before'. I would have expected '/' to return with 'main 0.166001'
while '/admin/' to halt. In other words I would expect that the
'hook before' is kept within the scope of the prefix '/admin' and
not bleed over to the undef prefix.<br>
<br>
Any ideas on what is happening? <br>
<br>
Thanks,<br>
<pre class="moz-signature" cols="72">--
Rick Westerman
<a class="moz-txt-link-abbreviated" href="mailto:westerman@purdue.edu">westerman@purdue.edu</a>
Bioinformatics specialist at the Genomics Facility.
Phone: (765) 494-0505 FAX: (765) 496-7255
Department of Horticulture and Landscape Architecture
625 Agriculture Mall Drive
West Lafayette, IN 47907-2010
Physically located in room S049, WSLR building</pre>
</body>
</html>