Sorry I have no experience with Dancer 2 or multiple contexts.<div><br></div><div>This works on Dancer 1, if it is any help:</div><div><br></div><div><div>#!/usr/bin/env perl</div><div><br></div><div>use Dancer;</div><div>
<br></div><div>{</div><div>    package App::Main;</div><div>    use Dancer &#39;:syntax&#39;;</div><div>    hook before =&gt; sub { var xxx =&gt; &quot;test&quot; };</div><div>    1;</div><div>}</div><div><br></div><div>{</div>
<div>    package App::Root;</div><div>    use Dancer &#39;:syntax&#39;;</div><div>    get &quot;/&quot; =&gt; sub { return vars-&gt;{xxx} };</div><div>    1;</div><div>}</div><div><br></div><div>start;</div><div><br></div>
<div>Good luck..</div><br><div class="gmail_quote">On 28 December 2012 17:25, Celogeek <span dir="ltr">&lt;<a href="mailto:me@celogeek.com" target="_blank">me@celogeek.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div style="font-size:12pt;font-family:times new roman,new york,times,serif"><div>it&#39;s just a not working short example :)<br></div><div><br></div><div>but Dancer use context, so in my App::Main I have a before hooks that only apply to the route present in App::Main.<br>
</div><div><br></div><div>So my App::Root doesn&#39;t have it. And it was the case in Dancer 1.<br></div><div><br></div><div>I need to fully change my apps to make it work with Dancer2<br></div><div><br></div><hr><div style="font-size:12pt;font-style:normal;font-family:Helvetica,Arial,sans-serif;text-decoration:none;font-weight:normal">
<b>De: </b>&quot;Alex C&quot; &lt;<a href="mailto:calyx238@gmail.com" target="_blank">calyx238@gmail.com</a>&gt;<br><b>À: </b>&quot;Perl Dancer users mailing list&quot; &lt;<a href="mailto:dancer-users@dancer.pm" target="_blank">dancer-users@dancer.pm</a>&gt;<br>
<b>Envoyé: </b>Vendredi 28 Décembre 2012 18:18:12<br><b>Objet: </b>Re: [dancer-users] Route dispatch<br><div><br></div>Yuo are missing the semicolons after your sub declarations. Try it agian ;)<br><div><br></div><div class="gmail_quote">
On 28 December 2012 15:57, Celogeek <span dir="ltr">&lt;<a href="mailto:me@celogeek.com" target="_blank">me@celogeek.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div style="font-size:12pt;font-family:times new roman,new york,times,serif"><div>Can I dispatch my root thought multiple module ?<br></div><div><br></div><div>I have in App::Main : <br></div><div><br></div><div>hook before =&gt; sub {<br>
</div><div>var xxx =&gt; &quot;test&quot;;<br></div><div>}<br></div><div><br></div><div>and in App::Root;<br></div><div><br></div><div>get &quot;/&quot; =&gt; sub {<br></div><div> return vars-&gt;{xxx}<br></div><div>}<br>
</div><div><br></div><div>But vars seems empty.<br></div><div><br></div><div>In my bin/app.psgi I have :<br></div><div><br></div><div>use Dancer;<br></div><div>use App::Main;<br></div><div>use App::Root;<br></div><div><br>
</div><div>start;<br></div><div><br></div><div><br></div></div></div><br>_______________________________________________<br> dancer-users mailing list<br> <a href="mailto:dancer-users@dancer.pm" target="_blank">dancer-users@dancer.pm</a><br>
 <a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" target="_blank">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a><br> <br></blockquote></div><br> <br>_______________________________________________<br>
dancer-users mailing list<br><a href="mailto:dancer-users@dancer.pm" target="_blank">dancer-users@dancer.pm</a><br><a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" target="_blank">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a><br>
</div><div><br></div></div></div><br>_______________________________________________<br>
dancer-users mailing list<br>
<a href="mailto:dancer-users@dancer.pm">dancer-users@dancer.pm</a><br>
<a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" target="_blank">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a><br>
<br></blockquote></div><br></div>