<div dir="ltr">I usually do the opposite<div><br></div><div>in MyApp I have the Dancer stuff,</div><div>in MyApp:: something I have the logical</div><div>I also separate the access to the data in another module</div><div><br>
</div><div>So I can test separately each part of my app</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/9/3 sawyer x <span dir="ltr">&lt;<a href="mailto:xsawyerx@gmail.com" target="_blank">xsawyerx@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Aug 29, 2013 at 12:31 PM, Adam Witney <span dir="ltr">&lt;<a href="mailto:awitney@sgul.ac.uk" target="_blank">awitney@sgul.ac.uk</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br>

On 28. 8. 2013 18:56, sawyer x wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br><div><div>
<br>
The way I suggest people write their website is by separating the<br>
application logic from the web layer. I usually implement an API with<br>
routes defined under MyApp/Web.pm. The rest of MyApp/ contains all the<br>
application logic that can survive and live without the web layer, if<br>
needs be.<br>
<br>
In your case, writing just the web layer would be very simple. You could<br>
then transition it to your use application, written in whatever language<br>
you want. If you write it correctly, you could switch from Dancer to a<br>
different web framework (whether in Perl or not).<br>
</div></div></blockquote>
<br>
Hi,<br>
<br>
I&#39;m interested in how exactly you write this API in the web layer, do you happen to have an example of this approach? or know of a project that uses it?<br></blockquote><div><br></div><div>I can&#39;t share any of the examples I have. They aren&#39;t open-source.<br>


</div><div>However, it&#39;s really not at all complicated.<br><br>Imagine having MyApp.pm that has:<br>use Moose; # or Moo<br></div><div>has ... <br>has ...<br><br></div><div>sub do_something {...}<br></div><div><br>and then you have MyApp/Web.pm that has:<br>


</div><div>use Dancer2;<br></div><div>my $app = MyApp-&gt;new;<br><br></div><div># define routes here<br></div><div>get &#39;/&#39; =&gt; sub { $app-&gt;do_something(...) };<br><br>-----<br><br></div><div>That way you separate the application logic from the web logic.<br>


</div></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>