<div dir="ltr">I didn't read the first email properly -- I think what you want to do is this:<div><br></div><div>in WebApp.pm:</div><div><br></div><div>package WebApp;</div><div><br></div><div>use Dancer2 appname => 'test';</div><div># plus the other dependencies<br></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">hook before => sub {</span><br style="font-size:13px"><span style="font-size:13px"> if (!session('user') && request->dispatch_path !~ m{^/login}) {</span><br style="font-size:13px"><span style="font-size:13px"> forward '/login', { requested_path => request->dispatch_path };</span><br style="font-size:13px"><span style="font-size:13px"> }</span><br style="font-size:13px"><span style="font-size:13px">};</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px">get '/' => sub { template 'index'; };</span><br style="font-size:13px"><span style="font-size:13px">get '/index' => sub { redirect '/' };</span><br style="font-size:13px"><br style="font-size:13px"></div><div># etc.</div><div><br></div><div>1;</div><div><br></div><div>in WebApp::API.pm:</div><div><br></div><div>package WebApp::API;</div><div><div>use Dancer2 appname => 'test';</div></div><div><br></div><div># handles everything under /api</div><div>prefix '/api' => sub {</div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px"> </span><span style="font-size:13px"> </span><span style="font-size:13px">any ['get', 'post'] => '/userdata/:user' => sub {</span><br style="font-size:13px"><br style="font-size:13px"><span style="font-size:13px"> </span><span style="font-size:13px"> </span><span style="font-size:13px"> </span><span style="font-size:13px">my $user_value = route_parameters->get('user');</span></div><div><span style="font-size:13px"> </span><span style="font-size:13px"> my $user = database->quick_select('users'</span><span style="font-size:13px">, { username => $user_value });</span><br style="font-size:13px"> <span style="font-size:13px"> </span><span style="font-size:13px"> </span># etc.</div><div> };</div><div>};<br></div><div><br></div><div>1;</div><div><br></div><div><br></div><div>in app.psgi:</div><div><br></div><div>use WebApp;</div><div>use WebApp::API;</div><div><br></div><div><div>builder {<br></div></div><div> mount '/' => WebApp->to_app # note that WebApp::API->to_app also works here<br></div><div>};</div><div><br></div><div>To make life even easier for yourself, you can make a wrapper to hold your various route modules:</div><div><br></div><div>package WebAppWrap;</div><div>use Dancer2 appname => 'test';</div><div>use WebApp;</div><div>use WebApp::API;</div><div>use WebApp::JSON;</div><div>use WebApp::Complex::Package; # each of these modules has appname 'test'</div><div># etc.</div><div><br></div><div>in app.psgi:</div><div><br></div><div>use WebAppWrap;</div><div><br></div><div>builder {</div><div> mount '/' => WebAppWrap->to_app # pulls in all loaded modules with appname 'test'</div><div>}; </div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 14 July 2016 at 18:53, James E Keenan <span dir="ltr"><<a href="mailto:jkeen@verizon.net" target="_blank">jkeen@verizon.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 07/14/2016 06:11 PM, Amelia Ireland wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Have you checked <a href="http://localhost:5000/api/api/userdata/dancer_operator" rel="noreferrer" target="_blank">http://localhost:5000/api/api/userdata/dancer_operator</a>?<br>
<br>
</blockquote></span>
Another 404 Not Found.<div class="HOEnZb"><div class="h5"><br>
<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" rel="noreferrer" target="_blank">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a><br>
</div></div></blockquote></div><br></div>