I usually do the opposite in MyApp I have the Dancer stuff, in MyApp:: something I have the logical I also separate the access to the data in another module So I can test separately each part of my app 2013/9/3 sawyer x <xsawyerx@gmail.com>
On Thu, Aug 29, 2013 at 12:31 PM, Adam Witney <awitney@sgul.ac.uk> wrote:
On 28. 8. 2013 18:56, sawyer x wrote:
The way I suggest people write their website is by separating the application logic from the web layer. I usually implement an API with routes defined under MyApp/Web.pm. The rest of MyApp/ contains all the application logic that can survive and live without the web layer, if needs be.
In your case, writing just the web layer would be very simple. You could then transition it to your use application, written in whatever language you want. If you write it correctly, you could switch from Dancer to a different web framework (whether in Perl or not).
Hi,
I'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?
I can't share any of the examples I have. They aren't open-source. However, it's really not at all complicated.
Imagine having MyApp.pm that has: use Moose; # or Moo has ... has ...
sub do_something {...}
and then you have MyApp/Web.pm that has: use Dancer2; my $app = MyApp->new;
# define routes here get '/' => sub { $app->do_something(...) };
-----
That way you separate the application logic from the web logic.
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users