.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Mojo 3pm" .TH Mojo 3pm "2017-01-24" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Mojo \- Web development toolkit .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& package MyApp; \& use Mojo::Base \*(AqMojo\*(Aq; \& \& # All the complexities of CGI, PSGI, HTTP and WebSockets get reduced to a \& # single method call! \& sub handler { \& my ($self, $tx) = @_; \& \& # Request \& my $method = $tx\->req\->method; \& my $path = $tx\->req\->url\->path; \& \& # Response \& $tx\->res\->code(200); \& $tx\->res\->headers\->content_type(\*(Aqtext/plain\*(Aq); \& $tx\->res\->body("$method request for $path!"); \& \& # Resume transaction \& $tx\->resume; \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" A powerful web development toolkit, with all the basic tools and helpers needed to write simple web applications and higher level web frameworks, such as Mojolicious. Some of the most commonly used tools are Mojo::UserAgent, Mojo::DOM, Mojo::JSON, Mojo::Server::Daemon, Mojo::Server::Prefork, Mojo::IOLoop and Mojo::Template. .PP See Mojolicious::Guides for more! .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" Mojo implements the following attributes. .SS "home" .IX Subsection "home" .Vb 2 \& my $home = $app\->home; \& $app = $app\->home(Mojo::Home\->new); .Ve .PP The home directory of your application, defaults to a Mojo::Home object which stringifies to the actual path. .PP .Vb 2 \& # Portably generate path relative to home directory \& my $path = $app\->home\->child(\*(Aqdata\*(Aq, \*(Aqimportant.txt\*(Aq); .Ve .SS "log" .IX Subsection "log" .Vb 2 \& my $log = $app\->log; \& $app = $app\->log(Mojo::Log\->new); .Ve .PP The logging layer of your application, defaults to a Mojo::Log object. .PP .Vb 2 \& # Log debug message \& $app\->log\->debug(\*(AqIt works\*(Aq); .Ve .SS "ua" .IX Subsection "ua" .Vb 2 \& my $ua = $app\->ua; \& $app = $app\->ua(Mojo::UserAgent\->new); .Ve .PP A full featured \s-1HTTP\s0 user agent for use in your applications, defaults to a Mojo::UserAgent object. .PP .Vb 2 \& # Perform blocking request \& say $app\->ua\->get(\*(Aqexample.com\*(Aq)\->res\->body; .Ve .SH "METHODS" .IX Header "METHODS" Mojo inherits all methods from Mojo::Base and implements the following new ones. .SS "build_tx" .IX Subsection "build_tx" .Vb 1 \& my $tx = $app\->build_tx; .Ve .PP Transaction builder, defaults to building a Mojo::Transaction::HTTP object. .SS "config" .IX Subsection "config" .Vb 4 \& my $hash = $app\->config; \& my $foo = $app\->config(\*(Aqfoo\*(Aq); \& $app = $app\->config({foo => \*(Aqbar\*(Aq, baz => 23}); \& $app = $app\->config(foo => \*(Aqbar\*(Aq, baz => 23); .Ve .PP Application configuration. .PP .Vb 2 \& # Remove value \& my $foo = delete $app\->config\->{foo}; \& \& # Assign multiple values at once \& $app\->config(foo => \*(Aqtest\*(Aq, bar => 23); .Ve .SS "handler" .IX Subsection "handler" .Vb 1 \& $app\->handler(Mojo::Transaction::HTTP\->new); .Ve .PP The handler is the main entry point to your application or framework and will be called for each new transaction, which will usually be a Mojo::Transaction::HTTP or Mojo::Transaction::WebSocket object. Meant to be overloaded in a subclass. .PP .Vb 4 \& sub handler { \& my ($self, $tx) = @_; \& ... \& } .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Mojolicious, Mojolicious::Guides, .