/
Mojo.pm
executable file
·207 lines (119 loc) · 3.11 KB
/
Mojo.pm
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
# Copyright (C) 2008-2009, Sebastian Riedel.
package Mojo;
use strict;
use warnings;
use base 'Mojo::Base';
# No imports to make subclassing a bit easier
require Carp;
use Mojo::Home;
use Mojo::Log;
use Mojo::Transaction;
__PACKAGE__->attr('home', default => sub { Mojo::Home->new });
__PACKAGE__->attr('log', default => sub { Mojo::Log->new });
# Oh, so they have internet on computers now!
our $VERSION = '0.991239';
sub new {
my $self = shift->SUPER::new(@_);
# Home
$self->home->detect(ref $self);
# Log directory
$self->log->path($self->home->rel_file('log/mojo.log'))
if -w $self->home->rel_file('log');
return $self;
}
sub build_tx {
my $tx = Mojo::Transaction->new;
$tx->res->headers->header('X-Powered-By' => 'Mojo (Perl)');
return $tx;
}
sub handler { Carp::croak('Method "handler" not implemented in subclass') }
1;
__END__
=head1 NAME
Mojo - The Web In A Box!
=head1 SYNOPSIS
use base 'Mojo';
sub handler {
my ($self, $tx) = @_;
# Hello world!
$tx->res->code(200);
$tx->res->headers->content_type('text/plain');
$tx->res->body('Congratulations, your Mojo is working!');
}
=head1 DESCRIPTION
L<Mojo> is a collection of libraries and example web frameworks for web
framework developers.
If you are searching for a higher level MVC web framework you should take a
look at L<Mojolicious>.
Don't be scared by the amount of different modules in the distribution, they
are all very loosely coupled.
You can just pick the ones you like and ignore the rest, there is no
tradeoff.
For userfriendly documentation see L<Mojo::Manual>.
=head1 ATTRIBUTES
L<Mojo> implements the following attributes.
=head2 C<home>
my $home = $mojo->home;
$mojo = $mojo->home(Mojo::Home->new);
=head2 C<log>
my $log = $mojo->log;
$mojo = $mojo->log(Mojo::Log->new);
=head1 METHODS
L<Mojo> inherits all methods from L<Mojo::Base> and implements the following
new ones.
=head2 C<new>
my $mojo = Mojo->new;
=head2 C<build_tx>
my $tx = $mojo->build_tx;
=head2 C<handler>
$tx = $mojo->handler($tx);
=head1 SUPPORT
=head2 Web
http://mojolicious.org
=head2 IRC
#mojo on irc.perl.org
=head2 Mailing-List
http://lists.kraih.com/listinfo/mojo
=head1 DEVELOPMENT
=head2 Repository
http://github.com/kraih/mojo/commits/master
=head1 SEE ALSO
L<Mojolicious>
=head1 AUTHOR
Sebastian Riedel, C<sri@cpan.org>.
=head1 CREDITS
In alphabetical order:
Anatoly Sharifulin
Andreas Koenig
Andy Grundman
Aristotle Pagaltzis
Ask Bjoern Hansen
Audrey Tang
Breno G. de Oliveira
Burak Gursoy
Ch Lamprecht
Christian Hansen
Gisle Aas
Graham Barr
James Duncan
Jesse Vincent
Lars Balker Rasmussen
Leon Brocard
Maik Fischer
Marcus Ramberg
Mark Stosberg
Maxym Komar
Pascal Gaudette
Pedro Melo
Randal Schwartz
Robert Hicks
Shu Cho
Uwe Voelker
vti
Yuki Kimoto
And thanks to everyone else i might have forgotten. (Please send me a mail)
=head1 COPYRIGHT
Copyright (C) 2008-2009, Sebastian Riedel.
This program is free software, you can redistribute it and/or modify it under
the same terms as Perl 5.10.
=cut