This file is indexed.

/usr/share/perl5/Mojolicious/Lite.pm is in libmojolicious-perl 7.59+dfsg-1ubuntu1.

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
package Mojolicious::Lite;
use Mojo::Base 'Mojolicious';

# "Bender: Bite my shiny metal ass!"
use Mojo::File 'path';
use Mojo::UserAgent::Server;
use Mojo::Util 'monkey_patch';

sub import {

  # Remember executable for later
  $ENV{MOJO_EXE} ||= (caller)[1];

  # Reuse home directory if possible
  local $ENV{MOJO_HOME} = path($ENV{MOJO_EXE})->dirname->to_string
    unless $ENV{MOJO_HOME};

  # Initialize application class
  my $caller = caller;
  no strict 'refs';
  push @{"${caller}::ISA"}, 'Mojo';

  # Generate moniker based on filename
  my $moniker = path($ENV{MOJO_EXE})->basename('.pl', '.pm', '.t');
  my $app = shift->new(moniker => $moniker);

  # Initialize routes without namespaces
  my $routes = $app->routes->namespaces([]);
  $app->static->classes->[0] = $app->renderer->classes->[0] = $caller;

  # The Mojolicious::Lite DSL
  my $root = $routes;
  for my $name (qw(any get options patch post put websocket)) {
    monkey_patch $caller, $name, sub { $routes->$name(@_) };
  }
  monkey_patch($caller, $_, sub {$app}) for qw(new app);
  monkey_patch $caller, del => sub { $routes->delete(@_) };
  monkey_patch $caller, group => sub (&) {
    (my $old, $root) = ($root, $routes);
    shift->();
    ($routes, $root) = ($root, $old);
  };
  monkey_patch $caller,
    helper => sub { $app->helper(@_) },
    hook   => sub { $app->hook(@_) },
    plugin => sub { $app->plugin(@_) },
    under  => sub { $routes = $root->under(@_) };

  # Make sure there's a default application for testing
  Mojo::UserAgent::Server->app($app) unless Mojo::UserAgent::Server->app;

  # Lite apps are strict!
  unshift @_, 'Mojo::Base', -strict;
  goto &Mojo::Base::import;
}

1;

=encoding utf8

=head1 NAME

Mojolicious::Lite - Micro real-time web framework

=head1 SYNOPSIS

  # Automatically enables "strict", "warnings", "utf8" and Perl 5.10 features
  use Mojolicious::Lite;

  # Route with placeholder
  get '/:foo' => sub {
    my $c   = shift;
    my $foo = $c->param('foo');
    $c->render(text => "Hello from $foo.");
  };

  # Start the Mojolicious command system
  app->start;

=head1 DESCRIPTION

L<Mojolicious::Lite> is a tiny domain specific language built around
L<Mojolicious>, made up of only about a dozen Perl functions.

On Perl 5.20+ you can also use a C<-signatures> flag to enable support for
L<subroutine signatures|perlsub/"Signatures">.

  use Mojolicious::Lite -signatures;

  get '/:foo' => sub ($c) {
    my $foo = $c->param('foo');
    $c->render(text => "Hello from $foo.");
  };

  app->start;

See L<Mojolicious::Guides::Tutorial> for more!

=head1 GROWING

While L<Mojolicious::Guides::Growing> will give you a detailed introduction to
growing a L<Mojolicious::Lite> prototype into a well-structured L<Mojolicious>
application, here we have collected a few snippets that illustrate very well
just how similar both of them are.

=head2 Routes

The functions L</"get">, L</"post"> and friends all have equivalent methods.

  # Mojolicious::Lite
  get '/foo' => sub {
    my $c = shift;
    $c->render(text => 'Hello World!');
  };

  # Mojolicious
  sub startup {
    my $self = shift;

    my $routes = $self->routes;
    $routes->get('/foo' => sub {
      my $c = shift;
      $c->render(text => 'Hello World!');
    });
  }

=head2 Application

The application object you can access with the function L</"app"> is the first
argument passed to the C<startup> method.

  # Mojolicious::Lite
  app->max_request_size(16777216);

  # Mojolicious
  sub startup {
    my $self = shift;
    $self->max_request_size(16777216);
  }

=head2 Plugins

Instead of the L</"plugin"> function you just use the method
L<Mojolicious/"plugin">.

  # Mojolicious::Lite
  plugin 'Config';

  # Mojolicious
  sub startup {
    my $self = shift;
    $self->plugin('Config');
  }

=head2 Helpers

Similar to plugins, instead of the L</"helper"> function you just use the method
L<Mojolicious/"helper">.

  # Mojolicious::Lite
  helper two => sub {
    my $c = shift;
    return 1 + 1;
  };

  # Mojolicious
  sub startup {
    my $self = shift;
    $self->helper(two => sub {
      my $c = shift;
      return 1 + 1;
    });
  }

=head2 Under

Instead of sequential function calls, we can use methods to build a tree with
nested routes, that much better illustrates how routes work internally.

  # Mojolicious::Lite
  under '/foo';
  get '/bar' => sub {...};

  # Mojolicious
  sub startup {
    my $self = shift;

    my $routes = $self->routes;
    my $foo = $routes->under('/foo');
    $foo->get('/bar' => sub {...});
  }

=head1 FUNCTIONS

L<Mojolicious::Lite> implements the following functions, which are
automatically exported.

=head2 any

  my $route = any '/:foo' => sub {...};
  my $route = any '/:foo' => sub {...} => 'name';
  my $route = any '/:foo' => {foo => 'bar'} => sub {...};
  my $route = any '/:foo' => [foo => qr/\w+/] => sub {...};
  my $route = any ['GET', 'POST'] => '/:foo' => sub {...};
  my $route = any ['GET', 'POST'] => '/:foo' => [foo => qr/\w+/] => sub {...};
  my $route = any
    ['GET', 'POST'] => '/:foo' => (agent => qr/Firefox/) => sub {...};

Generate route with L<Mojolicious::Routes::Route/"any">, matching any of the
listed HTTP request methods or all. See L<Mojolicious::Guides::Tutorial> and
L<Mojolicious::Guides::Routing> for more information.

=head2 app

  my $app = app;

Returns the L<Mojolicious::Lite> application object, which is a subclass of
L<Mojolicious>.

  # Use all the available attributes and methods
  app->log->level('error');
  app->defaults(foo => 'bar');

=head2 del

  my $route = del '/:foo' => sub {...};
  my $route = del '/:foo' => sub {...} => 'name';
  my $route = del '/:foo' => {foo => 'bar'} => sub {...};
  my $route = del '/:foo' => [foo => qr/\w+/] => sub {...};
  my $route = del '/:foo' => (agent => qr/Firefox/) => sub {...};

Generate route with L<Mojolicious::Routes::Route/"delete">, matching only
C<DELETE> requests. See L<Mojolicious::Guides::Tutorial> and
L<Mojolicious::Guides::Routing> for more information.

=head2 get

  my $route = get '/:foo' => sub {...};
  my $route = get '/:foo' => sub {...} => 'name';
  my $route = get '/:foo' => {foo => 'bar'} => sub {...};
  my $route = get '/:foo' => [foo => qr/\w+/] => sub {...};
  my $route = get '/:foo' => (agent => qr/Firefox/) => sub {...};

Generate route with L<Mojolicious::Routes::Route/"get">, matching only C<GET>
requests. See L<Mojolicious::Guides::Tutorial> and
L<Mojolicious::Guides::Routing> for more information.

=head2 group

  group {...};

Start a new route group.

=head2 helper

  helper foo => sub {...};

Add a new helper with L<Mojolicious/"helper">.

=head2 hook

  hook after_dispatch => sub {...};

Share code with L<Mojolicious/"hook">.

=head2 options

  my $route = options '/:foo' => sub {...};
  my $route = options '/:foo' => sub {...} => 'name';
  my $route = options '/:foo' => {foo => 'bar'} => sub {...};
  my $route = options '/:foo' => [foo => qr/\w+/] => sub {...};
  my $route = options '/:foo' => (agent => qr/Firefox/) => sub {...};

Generate route with L<Mojolicious::Routes::Route/"options">, matching only
C<OPTIONS> requests. See L<Mojolicious::Guides::Tutorial> and
L<Mojolicious::Guides::Routing> for more information.

=head2 patch

  my $route = patch '/:foo' => sub {...};
  my $route = patch '/:foo' => sub {...} => 'name';
  my $route = patch '/:foo' => {foo => 'bar'} => sub {...};
  my $route = patch '/:foo' => [foo => qr/\w+/] => sub {...};
  my $route = patch '/:foo' => (agent => qr/Firefox/) => sub {...};

Generate route with L<Mojolicious::Routes::Route/"patch">, matching only
C<PATCH> requests. See L<Mojolicious::Guides::Tutorial> and
L<Mojolicious::Guides::Routing> for more information.

=head2 plugin

  plugin SomePlugin => {foo => 23};

Load a plugin with L<Mojolicious/"plugin">.

=head2 post

  my $route = post '/:foo' => sub {...};
  my $route = post '/:foo' => sub {...} => 'name';
  my $route = post '/:foo' => {foo => 'bar'} => sub {...};
  my $route = post '/:foo' => [foo => qr/\w+/] => sub {...};
  my $route = post '/:foo' => (agent => qr/Firefox/) => sub {...};

Generate route with L<Mojolicious::Routes::Route/"post">, matching only C<POST>
requests. See L<Mojolicious::Guides::Tutorial> and
L<Mojolicious::Guides::Routing> for more information.

=head2 put

  my $route = put '/:foo' => sub {...};
  my $route = put '/:foo' => sub {...} => 'name';
  my $route = put '/:foo' => {foo => 'bar'} => sub {...};
  my $route = put '/:foo' => [foo => qr/\w+/] => sub {...};
  my $route = put '/:foo' => (agent => qr/Firefox/) => sub {...};

Generate route with L<Mojolicious::Routes::Route/"put">, matching only C<PUT>
requests. See L<Mojolicious::Guides::Tutorial> and
L<Mojolicious::Guides::Routing> for more information.

=head2 under

  my $route = under sub {...};
  my $route = under '/:foo' => sub {...};
  my $route = under '/:foo' => {foo => 'bar'};
  my $route = under '/:foo' => [foo => qr/\w+/];
  my $route = under '/:foo' => (agent => qr/Firefox/);
  my $route = under [format => 0];

Generate nested route with L<Mojolicious::Routes::Route/"under">, to which all
following routes are automatically appended. See
L<Mojolicious::Guides::Tutorial> and L<Mojolicious::Guides::Routing> for more
information.

=head2 websocket

  my $route = websocket '/:foo' => sub {...};
  my $route = websocket '/:foo' => sub {...} => 'name';
  my $route = websocket '/:foo' => {foo => 'bar'} => sub {...};
  my $route = websocket '/:foo' => [foo => qr/\w+/] => sub {...};
  my $route = websocket '/:foo' => (agent => qr/Firefox/) => sub {...};

Generate route with L<Mojolicious::Routes::Route/"websocket">, matching only
WebSocket handshakes. See L<Mojolicious::Guides::Tutorial> and
L<Mojolicious::Guides::Routing> for more information.

=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://mojolicious.org>.

=cut