last updated 2022-05-26
It is the current plan that this version number will be used for Perl at some point in the future.
Environment:
Nim code:
import asynchttpserver, asyncdispatch
use Mojolicious::Lite; | |
use DBM::Deep; | |
use Mojo::JWT; | |
plugin 'Bcrypt'; | |
plugin 'Minion' => {SQLite => 'minion.db'}; | |
helper users => sub { state $db = DBM::Deep->new('users.db') }; |
#!/usr/bin/env perl | |
use v5.10; | |
use strict; | |
use warnings; | |
use Mojolicious::Lite; | |
# Explicit use as a helper for PAR |
#!/bin/sh | |
die () { | |
msg="$1\n" | |
shift | |
printf "$msg" "$@" 1>&2 | |
exit 1 | |
} | |
use=` |
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
use experimental qw'signatures postderef'; | |
use Cwd; | |
app->attr( 'music_root' => sub { return $ENV{MUSIC_ROOT} || Cwd::cwd() } ); | |
push app->static->paths->@*, app->music_root; |
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
use DBIx::Connector; | |
my $dbname = $ENV{MOJO_DBNAME} || 'database.db'; | |
# add helper methods for interacting with database | |
helper connector => sub { | |
state $db = DBIx::Connector->new("dbi:SQLite:$dbname","","") or die "Could not connect"; |
use 5.20.0; | |
use feature qw(postderef signatures); | |
use Mojolicious::Lite; | |
use PadWalker 'peek_sub'; | |
hook around_action => sub ($next, $c, $action, @) { | |
my @params = sort grep {s/^\$param_//} keys peek_sub($action)->%*; | |
return $c->$action($c->param(\@params)); | |
}; |