/usr/share/perl5/Mojolicious/Lite.pm is in libmojolicious-perl 2.23-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 | package Mojolicious::Lite;
use Mojo::Base 'Mojolicious';
# "Since when is the Internet all about robbing people of their privacy?
# August 6, 1991."
use File::Basename 'dirname';
use File::Spec;
# "It's the future, my parents, my co-workers, my girlfriend,
# I'll never see any of them ever again... YAHOOO!"
sub import {
my $class = shift;
# Executable
$ENV{MOJO_EXE} ||= (caller)[1];
# Home
local $ENV{MOJO_HOME} =
File::Spec->catdir(split '/', dirname($ENV{MOJO_EXE}))
unless $ENV{MOJO_HOME};
# Initialize app
no strict 'refs';
my $caller = caller;
push @{"${caller}::ISA"}, $class;
my $app = $class->new;
# Initialize routes
my $routes = $app->routes;
$routes->namespace('');
# Default static and template class
$app->static->default_static_class($caller);
$app->renderer->default_template_class($caller);
# Export
no warnings 'redefine';
my $root = $routes;
*{"${caller}::new"} = *{"${caller}::app"} = sub {$app};
*{"${caller}::any"} = sub { $routes->any(@_) };
*{"${caller}::del"} = sub { $routes->delete(@_) };
*{"${caller}::get"} = sub { $routes->get(@_) };
*{"${caller}::group"} = sub (&) {
my $old = $root;
$_[0]->($root = $routes);
$routes = $root;
$root = $old;
};
*{"${caller}::helper"} = sub { $app->helper(@_) };
*{"${caller}::hook"} = sub { $app->hook(@_) };
*{"${caller}::under"} = *{"${caller}::ladder"} =
sub { $routes = $root->under(@_) };
*{"${caller}::plugin"} = sub { $app->plugin(@_) };
*{"${caller}::post"} = sub { $routes->post(@_) };
*{"${caller}::put"} = sub { $routes->put(@_) };
*{"${caller}::websocket"} = sub { $routes->websocket(@_) };
# We are most likely the app in a lite environment
$ENV{MOJO_APP} ||= $app;
# Shagadelic!
*{"${caller}::shagadelic"} = sub { $app->start(@_) };
# Lite apps are strict!
Mojo::Base->import(-strict);
}
1;
__END__
=head1 NAME
Mojolicious::Lite - Real-time micro web framework
=head1 SYNOPSIS
# Automatically enables "strict", "warnings" and Perl 5.10 features
use Mojolicious::Lite;
# Route with placeholder
get '/:foo' => sub {
my $self = shift;
my $foo = $self->param('foo');
$self->render(text => "Hello from $foo.");
};
# Start the Mojolicious command system
app->start;
=head1 DESCRIPTION
L<Mojolicious::Lite> is a micro real-time web framework built around
L<Mojolicious>.
=head1 TUTORIAL
A quick example driven introduction to the wonders of L<Mojolicious::Lite>.
Most of what you'll learn here also applies to normal L<Mojolicious>
applications.
=head2 Hello World
A simple Hello World application can look like this, L<strict>, L<warnings>
and Perl 5.10 features are automatically enabled and a few functions imported
when you use L<Mojolicious::Lite>, turning your script into a full featured
web application.
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => sub {
my $self = shift;
$self->render(text => 'Hello World!');
};
app->start;
=head2 Generator
There is also a helper command to generate a small example application.
$ mojo generate lite_app
=head2 Commands
All the normal L<Mojolicious::Commands> are available from the command line.
Note that CGI and PSGI environments can usually be auto detected and will
just work without commands.
$ ./myapp.pl daemon
Server available at http://127.0.0.1:3000.
$ ./myapp.pl daemon --listen http://*:8080
Server available at http://127.0.0.1:8080.
$ ./myapp.pl cgi
...CGI output...
$ ./myapp.pl
...List of available commands (or automatically detected environment)...
=head2 Start
The app->start call that starts the L<Mojolicious> command system can be
customized to override normal C<@ARGV> use.
app->start('cgi');
=head2 Reloading
Your application will automatically reload itself if you start it with the
C<morbo> development web server, so you don't have to restart the server
after every change.
$ morbo myapp.pl
Server available at http://127.0.0.1:3000.
=head2 Routes
Routes are basically just fancy paths that can contain different kinds of
placeholders.
C<$self> is an instance of L<Mojolicious::Controller> containing both the
HTTP request and response.
# /foo
get '/foo' => sub {
my $self = shift;
$self->render(text => 'Hello World!');
};
=head2 GET/POST parameters
All C<GET> and C<POST> parameters are accessible via C<param>.
# /foo?user=sri
get '/foo' => sub {
my $self = shift;
my $user = $self->param('user');
$self->render(text => "Hello $user.");
};
=head2 Stash and templates
The C<stash> is used to pass data to templates, which can be inlined in the
C<DATA> section.
# /bar
get '/bar' => sub {
my $self = shift;
$self->stash(one => 23);
$self->render('baz', two => 24);
};
__DATA__
@@ baz.html.ep
The magic numbers are <%= $one %> and <%= $two %>.
For more information about templates see also
L<Mojolicious::Guides::Rendering/"Embedded Perl">.
=head2 HTTP
L<Mojo::Message::Request> and L<Mojo::Message::Response> give you full access
to all HTTP features and information.
# /agent
get '/agent' => sub {
my $self = shift;
$self->res->headers->header('X-Bender' => 'Bite my shiny metal ass!');
$self->render(text => $self->req->headers->user_agent);
};
=head2 Route names
All routes can have a name associated with them, this allows automatic
template detection and back referencing with C<url_for>, C<link_to> and
C<form_for>.
Nameless routes get an automatically generated one assigned that is simply
equal to the route itself without non-word characters.
# /
get '/' => 'index';
# /hello
get '/hello';
__DATA__
@@ index.html.ep
<%= link_to Hello => 'hello' %>.
<%= link_to Reload => 'index' %>.
@@ hello.html.ep
Hello World!
=head2 Layouts
Templates can have layouts.
# /with_layout
get '/with_layout' => sub {
my $self = shift;
$self->render('with_layout');
};
__DATA__
@@ with_layout.html.ep
% title 'Green';
% layout 'green';
Hello World!
@@ layouts/green.html.ep
<!doctype html><html>
<head><title><%= title %></title></head>
<body><%= content %></body>
</html>
=head2 Blocks
Template blocks can be used like normal Perl functions and are always
delimited by the C<begin> and C<end> keywords.
# /with_block
get '/with_block' => 'block';
__DATA__
@@ block.html.ep
% my $link = begin
% my ($url, $name) = @_;
Try <%= link_to $url => begin %><%= $name %><% end %>.
% end
<!doctype html><html>
<head><title>Sebastians frameworks</title></head>
<body>
%= $link->('http://mojolicio.us', 'Mojolicious')
%= $link->('http://catalystframework.org', 'Catalyst')
</body>
</html>
=head2 Captured content
The C<content_for> helper can be used to pass around blocks of captured
content.
# /captured
get '/captured' => sub {
my $self = shift;
$self->render('captured');
};
__DATA__
@@ captured.html.ep
% layout 'blue', title => 'Green';
% content_for header => begin
<meta http-equiv="Pragma" content="no-cache">
% end
Hello World!
% content_for header => begin
<meta http-equiv="Expires" content="-1">
% end
@@ layouts/blue.html.ep
<!doctype html><html>
<head>
<title><%= title %></title>
%= content_for 'header'
</head>
<body><%= content %></body>
</html>
=head2 Helpers
You can also extend L<Mojolicious> with your own helpers, a list of all
built-in ones can be found in L<Mojolicious::Plugin::DefaultHelpers> and
L<Mojolicious::Plugin::TagHelpers>.
# "whois" helper
helper whois => sub {
my $self = shift;
my $agent = $self->req->headers->user_agent || 'Anonymous';
my $ip = $self->tx->remote_address;
return "$agent ($ip)";
};
# /secret
get '/secret' => sub {
my $self = shift;
my $user = $self->whois;
$self->app->log->debug("Request from $user.");
};
__DATA__
@@ secret.html.ep
We know who you are <%= whois %>.
=head2 Placeholders
Route placeholders allow capturing parts of a request path until a C</> or
C<.> separator occurs, results will be stored by name in the C<stash> and
C<param>.
# /foo/test
# /foo/test123
get '/foo/:bar' => sub {
my $self = shift;
my $bar = $self->stash('bar');
$self->render(text => "Our :bar placeholder matched $bar");
};
# /testsomething/foo
# /test123something/foo
get '/(:bar)something/foo' => sub {
my $self = shift;
my $bar = $self->param('bar');
$self->render(text => "Our :bar placeholder matched $bar");
};
=head2 Wildcard placeholders
Wildcard placeholders allow matching absolutely everything, including
C</> and C<.>.
# /hello/test
# /hello/test123
# /hello/test.123/test/123
get '/hello/*you' => 'groovy';
__DATA__
@@ groovy.html.ep
Your name is <%= $you %>.
=head2 HTTP methods
Routes can be restricted to specific request methods.
# GET /bye
get '/bye' => sub {
my $self = shift;
$self->render(text => 'Bye.');
};
# POST /bye
post '/bye' => sub {
my $self = shift;
$self->render(text => 'Bye.');
};
# GET|POST|DELETE /bye
any ['get', 'post', 'delete'] => '/bye' => sub {
my $self = shift;
$self->render(text => 'Bye.');
};
# * /baz
any '/baz' => sub {
my $self = shift;
my $method = $self->req->method;
$self->render(text => "You called /baz with $method");
};
=head2 Optional placeholders
Routes allow default values to make placeholders optional.
# /hello
# /hello/Sara
get '/hello/:name' => {name => 'Sebastian'} => sub {
my $self = shift;
$self->render('groovy', format => 'txt');
};
__DATA__
@@ groovy.txt.ep
My name is <%= $name %>.
=head2 Restrictive placeholders
The easiest way to make placeholders more restrictive are alternatives, you
just make a list of possible values.
# /test
# /123
any '/:foo' => [foo => ['test', 123]] => sub {
my $self = shift;
my $foo = $self->param('foo');
$self->render(text => "Our :foo placeholder matched $foo");
};
All placeholders get compiled to a regex internally, this process can also be
easily customized.
# /1
# /123
any '/:bar' => [bar => qr/\d+/] => sub {
my $self = shift;
my $bar = $self->param('bar');
$self->render(text => "Our :bar placeholder matched $bar");
};
Just make sure not to use C<^> and C<$> or capturing groups C<(...)>, because
placeholders become part of a larger regular expression internally,
C<(?:...)> is fine though.
=head2 Formats
Formats can be automatically detected by looking at file extensions.
# /detection.html
# /detection.txt
get '/detection' => sub {
my $self = shift;
$self->render('detected');
};
__DATA__
@@ detected.html.ep
<!doctype html><html>
<head><title>Detected</title></head>
<body>HTML was detected.</body>
</html>
@@ detected.txt.ep
TXT was detected.
Restrictive placeholders can also be used for format detection.
# /hello.json
# /hello.txt
get '/hello' => [format => ['json', 'txt']] => sub {
my $self = shift;
return $self->render_json({hello => 'world'})
if $self->stash('format') eq 'json';
$self->render_text('hello world');
};
=head2 Content negotiation
For resources with different representations and that require truly
C<RESTful> content negotiation you can also use C<respond_to>.
# /hello (Accept: application/json)
# /hello (Accept: text/xml)
# /hello.json
# /hello.xml
# /hello?format=json
# /hello?format=xml
get '/hello' => sub {
my $self = shift;
$self->respond_to(
json => {json => {hello => 'world'}},
xml => {text => '<hello>world</hello>'},
any => {data => '', status => 204}
);
};
MIME type mappings can be extended or changed easily with
L<Mojolicious/"types">.
app->types->type(rdf => 'application/rdf+xml');
=head2 Under
Authentication and code shared between multiple routes can be realized easily
with the C<under> statement.
All following routes are only evaluated if the C<under> callback returned a
true value.
use Mojolicious::Lite;
# Authenticate based on name parameter
under sub {
my $self = shift;
# Authenticated
my $name = $self->param('name') || '';
return 1 if $name eq 'Bender';
# Not authenticated
$self->render('denied');
return;
};
# / (with authentication)
get '/' => 'index';
app->start;
__DATA__;
@@ denied.html.ep
You are not Bender, permission denied.
@@ index.html.ep
Hi Bender.
Prefixing multiple routes is another good use for C<under>.
use Mojolicious::Lite;
# /foo
under '/foo';
# /foo/bar
get '/bar' => {text => 'foo bar'};
# /foo/baz
get '/baz' => {text => 'foo baz'};
# /
under '/' => {message => 'whatever'};
# /bar
get '/bar' => {inline => '<%= $message %> works'};
app->start;
You can also C<group> related routes, which allows nesting of multiple
C<under> statements.
use Mojolicious::Lite;
# Global logic shared by all routes
under sub {
my $self = shift;
return 1 if $self->req->headers->header('X-Bender');
$self->render(text => "You're not Bender.");
return;
};
# Admin section
group {
# Local logic shared only by routes in this group
under '/admin' => sub {
my $self = shift;
return 1 if $self->req->heaers->header('X-Awesome');
$self->render(text => "You're not awesome enough.");
return;
};
# GET /admin/dashboard
get '/dashboard' => {text => 'Nothing to see here yet.'};
};
# GET /welcome
get '/welcome' => {text => 'Hi Bender.'};
app->start;
=head2 Conditions
Conditions such as C<agent> and C<host> from
L<Mojolicious::Plugin::HeaderCondition> allow even more powerful route
constructs.
# /foo (Firefox)
get '/foo' => (agent => qr/Firefox/) => sub {
my $self = shift;
$self->render(text => 'Congratulations, you are using a cool browser.');
};
# /foo (Internet Explorer)
get '/foo' => (agent => qr/Internet Explorer/) => sub {
my $self = shift;
$self->render(text => 'Dude, you really need to upgrade to Firefox.');
};
# http://mojolicio.us/bar
get '/bar' => (host => 'mojolicio.us') => sub {
my $self = shift;
$self->render(text => 'Hello Mojolicious.');
};
=head2 Sessions
Signed cookie based sessions just work out of the box as soon as you start
using them.
use Mojolicious::Lite;
get '/counter' => sub {
my $self = shift;
$self->session->{counter}++;
};
app->start;
__DATA__
@@ counter.html.ep
Counter: <%= session 'counter' %>
=head2 Secret
Note that you should use a custom C<secret> to make signed cookies really
secure.
app->secret('My secret passphrase here');
=head2 File uploads
All files uploaded via C<multipart/form-data> request are automatically
available as L<Mojo::Upload> instances.
And you don't have to worry about memory usage, because all files above
C<250KB> will be automatically streamed into a temporary file.
use Mojolicious::Lite;
any '/upload' => sub {
my $self = shift;
if (my $example = $self->req->upload('example')) {
my $size = $example->size;
my $name = $example->filename;
$self->render(text => "Thanks for uploading $size byte file $name.");
}
};
app->start;
__DATA__
@@ upload.html.ep
<!doctype html><html>
<head><title>Upload</title></head>
<body>
% my @attrs = (method => 'POST', enctype => 'multipart/form-data');
%= form_for upload => @attrs => begin
%= file_field 'example'
%= submit_button 'Upload'
% end
</body>
</html>
To protect you from excessively large files there is also a limit of C<5MB>
by default, which you can tweak with the C<MOJO_MAX_MESSAGE_SIZE> environment
variable.
# Increase limit to 1GB
$ENV{MOJO_MAX_MESSAGE_SIZE} = 1073741824;
=head2 User agent
With L<Mojo::UserAgent> there's a full featured HTTP 1.1 and WebSocket user
agent built right in.
Especially in combination with L<Mojo::JSON> and L<Mojo::DOM> this can be a
very powerful tool.
get '/test' => sub {
my $self = shift;
$self->render(data => $self->ua->get('http://mojolicio.us')->res->body);
};
=head2 WebSockets
WebSocket applications have never been this easy before.
websocket '/echo' => sub {
my $self = shift;
$self->on(message => sub {
my ($self, $message) = @_;
$self->send_message("echo: $message");
});
};
The C<message> event will be emitted for every new WebSocket message that is
received.
=head2 External templates
External templates will be searched by the renderer in a C<templates>
directory.
# /external
any '/external' => sub {
my $self = shift;
# templates/foo/bar.html.ep
$self->render('foo/bar');
};
=head2 Static files
Static files will be automatically served from the C<DATA> section
(even Base64 encoded) or a C<public> directory if it exists.
@@ something.js
alert('hello!');
@@ test.txt (base64)
dGVzdCAxMjMKbGFsYWxh
$ mkdir public
$ mv something.js public/something.js
=head2 Testing
Testing your application is as easy as creating a C<t> directory and filling
it with normal Perl unit tests.
use Test::More tests => 3;
use Test::Mojo;
use FindBin;
require "$FindBin::Bin/../myapp.pl";
my $t = Test::Mojo->new;
$t->get_ok('/')->status_is(200)->content_like(qr/Funky/);
Run all unit tests with the C<test> command.
$ ./myapp.pl test
To make your tests more noisy and show you all log messages you can also
change the application log level directly in your test files.
$t->app->log->level('debug');
=head2 Mode
To disable debug messages later in a production setup you can change the
L<Mojolicious> mode, default will be C<development>.
$ ./myapp.pl --mode production
=head2 Logging
L<Mojo::Log> messages will be automatically written to C<STDERR> or a
C<log/$mode.log> file if a C<log> directory exists.
$ mkdir log
For more control the L<Mojolicious> instance can be accessed directly.
app->log->level('error');
app->routes->route('/foo/:bar')->via('GET')->to(cb => sub {
my $self = shift;
$self->app->log->debug('Got a request for "Hello Mojo!".');
$self->render(text => 'Hello Mojo!');
});
=head2 Growing
In case a lite app needs to grow, lite and real L<Mojolicious> applications
can be easily mixed to make the transition process very smooth.
package MyApp::Foo;
use Mojo::Base 'Mojolicious::Controller';
sub index {
my $self = shift;
$self->render(text => 'It works.');
}
package main;
use Mojolicious::Lite;
get '/bar' => sub {
my $self = shift;
$self->render(text => 'This too.');
};
app->routes->namespace('MyApp');
app->routes->route('/foo/:action')->via('GET')->to('foo#index');
app->start;
There is also a helper command to generate a full L<Mojolicious> example that
will let you explore the astonishing similarities between
L<Mojolicious::Lite> and L<Mojolicious> applications.
Both share about 99% of the same code, so almost everything you learned in
this tutorial applies there too. :)
$ mojo generate app
=head2 More
You can continue with L<Mojolicious::Guides> now, and don't forget to have
fun!
=head1 FUNCTIONS
L<Mojolicious::Lite> implements the following functions.
=head2 C<any>
my $route = any '/:foo' => sub {...};
my $route = any ['get', 'post'] => '/:foo' => sub {...};
Generate route matching any of the listed HTTP request methods or all.
See also the tutorial above for more argument variations.
=head2 C<app>
my $app = app;
The L<Mojolicious::Lite> application.
=head2 C<del>
my $route = del '/:foo' => sub {...};
Generate route matching only C<DELETE> requests.
See also the tutorial above for more argument variations.
=head2 C<get>
my $route = get '/:foo' => sub {...};
Generate route matching only C<GET> requests.
See also the tutorial above for more argument variations.
=head2 C<group>
group {...};
Start a new route group.
Note that this function is EXPERIMENTAL and might change without warning!
=head2 C<helper>
helper foo => sub {...};
Alias for L<Mojolicious/"helper">.
=head2 C<hook>
hook after_dispatch => sub {...};
Alias for L<Mojolicious/"hook">.
=head2 C<plugin>
plugin 'SomeThing';
Alias for L<Mojolicious/"plugin">.
=head2 C<post>
my $route = post '/:foo' => sub {...};
Generate route matching only C<POST> requests.
See also the tutorial above for more argument variations.
=head2 C<put>
my $route = put '/:foo' => sub {...};
Generate route matching only C<PUT> requests.
See also the tutorial above for more argument variations.
=head2 C<under>
my $route = under sub {...};
my $route = under '/:foo';
Generate bridge to which all following routes are automatically appended.
See also the tutorial above for more argument variations.
=head2 C<websocket>
my $route = websocket '/:foo' => sub {...};
Generate route matching only C<WebSocket> handshakes.
See also the tutorial above for more argument variations.
=head1 ATTRIBUTES
L<Mojolicious::Lite> inherits all attributes from L<Mojolicious>.
=head1 METHODS
L<Mojolicious::Lite> inherits all methods from L<Mojolicious>.
=head1 SEE ALSO
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>.
=cut
|