1 | package Mojo;
|
---|
2 | use Mojo::Base -strict;
|
---|
3 |
|
---|
4 | # "Professor: These old Doomsday devices are dangerously unstable. I'll rest
|
---|
5 | # easier not knowing where they are."
|
---|
6 | use Mojo::Log;
|
---|
7 | use Mojo::Transaction::HTTP;
|
---|
8 | use Mojo::Util 'deprecated';
|
---|
9 |
|
---|
10 | # DEPRECATED!
|
---|
11 | sub build_tx {
|
---|
12 | deprecated 'Mojo::build_tx is DEPRECATED in favor of Mojolicious::build_tx';
|
---|
13 | Mojo::Transaction::HTTP->new;
|
---|
14 | }
|
---|
15 |
|
---|
16 | # DEPRECATED!
|
---|
17 | sub config {
|
---|
18 | deprecated 'Mojo::config is DEPRECATED in favor of Mojolicious::config';
|
---|
19 | Mojo::Util::_stash(config => @_);
|
---|
20 | }
|
---|
21 |
|
---|
22 | # DEPRECATED!
|
---|
23 | sub log {
|
---|
24 | deprecated 'Mojo::log is DEPRECATED in favor of Mojolicious::log';
|
---|
25 | my $self = shift;
|
---|
26 | return $self->{log} unless @_;
|
---|
27 | $self->{log} = Mojo::Log->new // shift;
|
---|
28 | return $self;
|
---|
29 | }
|
---|
30 |
|
---|
31 | # DEPRECATED!
|
---|
32 | sub handler {
|
---|
33 | deprecated 'Mojo::handler is DEPRECATED in favor of Mojolicious::handler';
|
---|
34 | }
|
---|
35 |
|
---|
36 | 1;
|
---|
37 |
|
---|
38 | =encoding utf8
|
---|
39 |
|
---|
40 | =head1 NAME
|
---|
41 |
|
---|
42 | Mojo - Web development toolkit
|
---|
43 |
|
---|
44 | =head1 SYNOPSIS
|
---|
45 |
|
---|
46 | # HTTP/WebSocket user agent
|
---|
47 | use Mojo::UserAgent;
|
---|
48 | my $ua = Mojo::UserAgent->new;
|
---|
49 | say $ua->get('www.mojolicious.org')->result->headers->server;
|
---|
50 |
|
---|
51 | # HTML/XML DOM parser with CSS selectors
|
---|
52 | use Mojo::DOM;
|
---|
53 | my $dom = Mojo::DOM->new('<div><b>Hello Mojo!</b></div>');
|
---|
54 | say $dom->at('div > b')->text;
|
---|
55 |
|
---|
56 | # Perl-ish templates
|
---|
57 | use Mojo::Template;
|
---|
58 | my $mt = Mojo::Template->new(vars => 1);
|
---|
59 | say $mt->render('Hello <%= $what %>!', {what => 'Mojo'});
|
---|
60 |
|
---|
61 | # HTTP/WebSocket server
|
---|
62 | use Mojo::Server::Daemon;
|
---|
63 | my $daemon = Mojo::Server::Daemon->new(listen => ['http://*:8080']);
|
---|
64 | $daemon->unsubscribe('request')->on(request => sub {
|
---|
65 | my ($daemon, $tx) = @_;
|
---|
66 | $tx->res->code(200);
|
---|
67 | $tx->res->body('Hello Mojo!');
|
---|
68 | $tx->resume;
|
---|
69 | });
|
---|
70 | $daemon->run;
|
---|
71 |
|
---|
72 | # Event loop
|
---|
73 | use Mojo::IOLoop;
|
---|
74 | for my $seconds (1 .. 5) {
|
---|
75 | Mojo::IOLoop->timer($seconds => sub { say $seconds });
|
---|
76 | }
|
---|
77 | Mojo::IOLoop->start;
|
---|
78 |
|
---|
79 | =head1 DESCRIPTION
|
---|
80 |
|
---|
81 | A powerful web development toolkit, with all the basic tools and helpers needed
|
---|
82 | to write simple web applications and higher level web frameworks, such as
|
---|
83 | L<Mojolicious>. Some of the most commonly used tools are L<Mojo::UserAgent>,
|
---|
84 | L<Mojo::DOM>, L<Mojo::JSON>, L<Mojo::Server::Daemon>, L<Mojo::Server::Prefork>,
|
---|
85 | L<Mojo::IOLoop> and L<Mojo::Template>.
|
---|
86 |
|
---|
87 | See L<Mojolicious::Guides> for more!
|
---|
88 |
|
---|
89 | =head1 SEE ALSO
|
---|
90 |
|
---|
91 | L<Mojolicious>, L<Mojolicious::Guides>, L<https://mojolicious.org>.
|
---|
92 |
|
---|
93 | =cut
|
---|