56. WEBSOCKET REVOLUTION!
•HTML5 protocol for long running processes
•Mojo first Perl framework to add support
•perl -MMojolicious::Lite -e "websocket '/' =>
sub {shift->receive_message(sub { shift-
>send_message(shift)})}; shagadelic 'daemon'"
•github.com/vti - web socket goodness
•Suppports latest revision of the spec.
61. $ mojo generate lite_app tinyws
[exist] /Users/marcus
[write] /Users/marcus/tinyws
[chmod] tinyws 744
• That was easy. Now let’s check out the contents of the file
64. % ./tinyws
usage: ./tinyws COMMAND [OPTIONS]
Tip: CGI, FastCGI and PSGI environments can be automatically detected very
often and work without commands.
These commands are currently available:
cgi Start application with CGI.
daemon Start application with HTTP 1.1 and WebSocket server.
fastcgi Start application with FastCGI.
generate Generate files and directories from templates.
get Get file from URL.
hypnotoad Start application with Hypnotoad.
inflate Inflate embedded files to real files.
psgi Start application with PSGI.
routes Show available routes.
test Run unit tests.
version Show versions of installed modules.
daemon_prefork Start application with preforking HTTP 1.1 backend.
These options are available for all commands:
--home <path> Path to your applications home directory, defaults to
the value of MOJO_HOME or auto detection.
--mode <name> Run mode of your application, defaults to the value of
MOJO_MODE or development.
See './tinyws help COMMAND' for more information on a specific command.
66. # ::Lite
get ‘/’ => ‘index’;
# sub refs for functions
post ‘/login’ => sub { .. };
# Placeholders & Actions:
get ‘/:foo’ => sub {},‘ctrl’
# All together
get '/everything/:stuff' => [stuff => qr/d+/]
=> {stuff => 23} =>
sub { shift->render('welcome'); }
67. ladder sub {
my $self = shift
# Authenticated
my $name = $self->param('name') || '';
return 1 if $name eq 'Bender';
# Not authenticated
$self->render('denied');
return;
}
68. $ mojo generate app tinyws2
[write] /Users/marcus/tinyws2/script/tinyws2
[write] /Users/marcus/tinyws2/lib/tinyws2.pm
[write] /Users/marcus/tinyws2/lib/tinyws2/Example.pm
[write] /Users/marcus/tinyws2/t/basic.t
[write] /Users/marcus/tinyws2/public/index.html
[write] /Users/marcus/tinyws2/templates/not_found.html.ep
[write] /Users/marcus/tinyws2/templates/exception.html.ep
[write] /Users/marcus/tinyws2/templates/layouts/default.html.ep
[write] /Users/marcus/tinyws2/templates/example/welcome.html.ep
Snipped out all the mkdir/chmod for brevity.
69. $r->route(‘/’)->to
(controller=>‘foo’,action=> ‘bar’);
('lists#new', id => 1)->name('new');
('/:controller/:action/:id')->to
('example#welcome', id => 1)
# Bridges
my $auth=$r->bridge->to(‘auth#check’);
$auth->route(...)
71. % my $player=$self->stash(‘players’);
%= $player; # print
%== $player; # raw
<%= player %> <%== player %> # inline style
% # Normal comment
<% # inline comment %>
.ep - prepopulates stash for you
.epl - same templates, less magic
84. All glory to the
Hypnotoad
•Production ready standalone server
•Hot deployment using unix signals
•Set up Worker threads, pid file, reverse proxy
support through a simple config file
•Web Socket support.
87. Server:
"INT", "TERM"Shutdown server
"QUIT" Shutdown server gracefully
"TTIN" Increase worker pool by one
"TTOU" Decrease worker pool by one
"USR2" hot deployment.
Worker:
"INT", "TERM"Shutdown server
"QUIT" Shutdown server gracefully
CPAN id MRAMBERG \nFirst core developer to join the Catalyst framework.\n
\n
At the city center\n
\nof a little city far north \n\n
Where Polar bears and penguins walk the street\n
And parrots are pining for the fjords\n
Started together with Arne 3 years ago\nSurprisingly Nordic company\n\n
We focus on mobile, lean, useful apps, mostly in Perl and Obj-c.\n
\n
\n
\n
\n
\n
500 sqm\nStill within 3 minutes of Oslo central station\n
Coworking in Oslo - Drop in & regular\n
Tonight&#x2019;s feature presentation\n
Present to you Mojolicious\nLWP for the Next Decade.\n
\n
Hoppy Frood from the south of Germany\nSometimes claims to be a bot\nKnown aliases kraih at Twitter, &#x2018;sri&#x2019; on irc\n\n
First Time I heard of Sebastian - Maypole Mailing lists\nMaypole was originally developed by Simon Cozens, \nbut he decided to become a missionary in Japan.\n
\n
Catalyst had gathered steam.\nCore team of developers\n
\n
Took a break from Perl - Ruby and World of Warcraft\nCame back with Mojolicious - Originally a Framework Construction Kit\n
\n
\n
\n
Runs in 30 seconds (time to download, run test suite and install files). \n
\n
\n
\n
\n
Tell about nginx and status phrases.\n
\n
\n
\n
\n
\n
\n
\n
So, I showed a quick example of an Oneliner earlier\n
ojo package is a ...\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
(temp storage on filesystem)\n
\n
\n
\n
\n
\n
\n
\n
Continues on next slide\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Of course, if you&#x2019;re like me, you can just use the TT renderer instead\nThere&#x2019;s even a plugin to set it up for you.\n
Or one of the other renderers on CPAN\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Like 60% of the IRC channel speaks russian.\nEarly Mojolicious presentations at russian Perl events.\n\n