<div dir="ltr">Have you checked <a href="http://localhost:5000/api/api/userdata/dancer_operator" rel="noreferrer" target="_blank" style="font-size:13px">http://localhost:5000/api/api/userdata/dancer_operator</a>?</div><div class="gmail_extra"><br><div class="gmail_quote">On 14 July 2016 at 14:37, 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/12/2016 10:44 AM, Warren Young wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Jul 10, 2016, at 11:20 AM, James E Keenan <<a href="mailto:jkeen@verizon.net" target="_blank">jkeen@verizon.net</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
All the endpoints defined in lib/<a href="http://mywebapp.pm" rel="noreferrer" target="_blank">mywebapp.pm</a> continue to function as expected. But the endpoint, /api/userdata/:user, defined in lib/mywebapp/<a href="http://api.pm" rel="noreferrer" target="_blank">api.pm</a>, no longer works.<br>
</blockquote>
<br>
That’s because your “mount” for the <a href="http://api.pm" rel="noreferrer" target="_blank">api.pm</a> routes prepends ‘/api’ to them. When you use the module standalone as you’re attempting to now, that bit is stripped off. You’ll find that you now have /userdata/$stuff now.<br>
<br>
Easy fix: wrap the route definitions in <a href="http://api.pm" rel="noreferrer" target="_blank">api.pm</a> in a prefix block:<br>
<br>
prefix '/api' => sub {<br>
any ['get', 'post'] => '/userdata/:user' => sub {<br>
# etc<br>
};<br>
};<br>
<br>
</blockquote>
<br></span>
Thank you for your reply. However, when I wrap the endpoint in mywebapp::api with 'prefix' per your suggestion, I am still getting 404s on both '<a href="http://localhost:5000/api/userdata/dancer_operator" rel="noreferrer" target="_blank">http://localhost:5000/api/userdata/dancer_operator</a>' and '<a href="http://localhost:5000/userdata/dancer_operator" rel="noreferrer" target="_blank">http://localhost:5000/userdata/dancer_operator</a>'.<br>
<br>
Here is the diff of what I am trying:<span class=""><br>
<br>
#####<br>
diff --git a/bin/app.psgi b/bin/app.psgi<br></span>
index 46d8845..e9ac3da 100755<br>
--- a/bin/app.psgi<br>
+++ b/bin/app.psgi<br>
@@ -6,11 +6,12 @@ use FindBin;<span class=""><br>
use lib "$FindBin::Bin/../lib";<br>
<br>
use mywebapp;<br>
-use mywebapp::api;<br>
-use Plack::Builder;<br>
-<br>
-builder {<br>
- mount '/' => mywebapp->to_app;<br>
- mount '/api' => mywebapp::api->to_app;<br>
-};<br></span>
+#use mywebapp::api;<br>
+#use Plack::Builder;<br>
+#<br>
+#builder {<br>
+# mount '/' => mywebapp->to_app;<br>
+# mount '/api' => mywebapp::api->to_app;<br>
+#};<br>
+mywebapp->to_app;<br>
<br>
diff --git a/lib/<a href="http://mywebapp.pm" rel="noreferrer" target="_blank">mywebapp.pm</a> b/lib/<a href="http://mywebapp.pm" rel="noreferrer" target="_blank">mywebapp.pm</a><br>
index 997bdc7..7c940da 100644<br>
--- a/lib/<a href="http://mywebapp.pm" rel="noreferrer" target="_blank">mywebapp.pm</a><br>
+++ b/lib/<a href="http://mywebapp.pm" rel="noreferrer" target="_blank">mywebapp.pm</a><br>
@@ -1,6 +1,6 @@<br>
package mywebapp;<span class=""><br>
use v5.10.1;<br>
-use Dancer2;<br>
+use Dancer2 appname => mywebapp;<br>
use Dancer2::Plugin::Database;<br>
use Crypt::SaltedHash;<br>
use Data::Dump;<br></span>
diff --git a/lib/mywebapp/<a href="http://api.pm" rel="noreferrer" target="_blank">api.pm</a> b/lib/mywebapp/<a href="http://api.pm" rel="noreferrer" target="_blank">api.pm</a><br>
index 3af1adf..88b47f7 100644<span class=""><br>
--- a/lib/mywebapp/<a href="http://api.pm" rel="noreferrer" target="_blank">api.pm</a><br>
+++ b/lib/mywebapp/<a href="http://api.pm" rel="noreferrer" target="_blank">api.pm</a><br>
@@ -1,6 +1,6 @@<br>
package mywebapp::api;<br>
use v5.10.1;<br>
-use Dancer2;<br>
+use Dancer2 appname => mywebapp;<br>
use Dancer2::Plugin::Database;<br>
use Crypt::SaltedHash;<br>
use Data::Dump;<br></span>
@@ -13,6 +13,7 @@ set session => 'Simple';<span class=""><br>
set views => path( app->location, "templates" );<br>
set serializer => 'JSON';<br>
<br></span>
+prefix '/api' => sub {<span class=""><br>
any ['get', 'post'] => '/userdata/:user' => sub {<br>
<br></span><span class="">
my $user_value = route_parameters->get('user');<br></span>
@@ -34,6 +35,7 @@ any ['get', 'post'] => '/userdata/:user' => sub {<br>
}<br>
}<br>
};<br>
+};<br>
<br>
start;<br>
######<br>
<br>
So I'm still finding that 'appname' is not DWIMming.<span class="im HOEnZb"><br>
<br>
Thank you very much.<br>
Jim Keenan<br></span><div class="HOEnZb"><div class="h5">
_______________________________________________<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>