diff --git a/Procfile b/Procfile new file mode 100755 index 0000000..f4461bd --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: ./script/lrrr daemon --listen http://*:$PORT diff --git a/cpanfile b/cpanfile new file mode 100644 index 0000000..f6771e2 --- /dev/null +++ b/cpanfile @@ -0,0 +1,2 @@ +requires 'Mojolicious' +requires 'Mojolicious::Plugin::Authentication' diff --git a/lib/.Lrrr.pm.swp b/lib/.Lrrr.pm.swp new file mode 100644 index 0000000..f0e76c7 Binary files /dev/null and b/lib/.Lrrr.pm.swp differ diff --git a/lib/Lrrr.pm b/lib/Lrrr.pm new file mode 100644 index 0000000..35c5406 --- /dev/null +++ b/lib/Lrrr.pm @@ -0,0 +1,44 @@ +package Lrrr; +use Mojo::Base 'Mojolicious'; + +# This method will run once at server start +sub startup { + my $self = shift; + + # Documentation browser under "/perldoc" + $self->plugin('PODRenderer'); + + # auth + $self->plugin( authentication => { + autoload_user => 1, + load_user => sub { + my $self = shift; + my $uid = shift; + + return { + 'username' => 'foo', + 'password' => 'bar', + 'name' => 'Foo' + } if($uid eq 'userid' || $uid eq 'useridwithextradata'); + return undef; + }, + validate_user => sub { + my $self = shift; + my $username = shift || ''; + my $password = shift || ''; + my $extradata = shift || {}; + + return 'useridwithextradata' if($username eq 'foo' && $password eq 'bar' && ( $extradata->{'ohnoes'} || '' ) eq 'itsameme'); + return 'userid' if($username eq 'foo' && $password eq 'bar'); + return undef; + }, + }); + + # Router + my $r = $self->routes; + + # Normal route to controller + $r->get('/')->to('example#welcome'); +} + +1; diff --git a/lib/Lrrr/Example.pm b/lib/Lrrr/Example.pm new file mode 100644 index 0000000..a9c1767 --- /dev/null +++ b/lib/Lrrr/Example.pm @@ -0,0 +1,12 @@ +package Lrrr::Example; +use Mojo::Base 'Mojolicious::Controller'; + +# This action will render a template +sub welcome { + my $self = shift; + + # Render template "example/welcome.html.ep" with message + $self->render(msg => 'Welcome to the Mojolicious real-time web framework!'); +} + +1; diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..e74bb5f --- /dev/null +++ b/public/index.html @@ -0,0 +1,11 @@ + + +
+