Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

mojo(3pm) [debian man page]

Mojo(3pm)						User Contributed Perl Documentation						 Mojo(3pm)

NAME
Mojo - Duct tape for the HTML5 web! SYNOPSIS
use Mojo::Base 'Mojo'; # 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('text/plain'); $tx->res->body("$method request for $path!"); # Resume transaction $tx->resume; } DESCRIPTION
Mojo provides a flexible runtime environment for Perl real-time web frameworks. It provides all the basic tools and helpers needed to write simple web applications and higher level web frameworks such as Mojolicious. See Mojolicious for more! ATTRIBUTES
Mojo implements the following attributes. "home" my $home = $app->home; $app = $app->home(Mojo::Home->new); The home directory of your application, defaults to a Mojo::Home object which stringifies to the actual path. # Generate portable path relative to home directory my $path = $app->home->rel_file('data/important.txt'); "log" my $log = $app->log; $app = $app->log(Mojo::Log->new); The logging layer of your application, defaults to a Mojo::Log object. # Log debug message $app->log->debug('It works!'); "ua" my $ua = $app->ua; $app = $app->ua(Mojo::UserAgent->new); A full featured HTTP 1.1 user agent for use in your applications, defaults to a Mojo::UserAgent object. Note that this user agent should not be used in plugins, since non-blocking requests that are already in progress will interfere with new blocking ones. # Perform blocking request my $body = $app->ua->get('mojolicio.us')->res->body; METHODS
Mojo inherits all methods from Mojo::Base and implements the following new ones. "new" my $app = Mojo->new; Construct a new Mojo application. Will automatically detect your home directory and set up logging to "log/mojo.log" if there's a "log" directory. "build_tx" my $tx = $app->build_tx; Transaction builder, defaults to building a Mojo::Transaction::HTTP object. "config" my $config = $app->config; my $foo = $app->config('foo'); $app = $app->config({foo => 'bar'}); $app = $app->config(foo => 'bar'); Application configuration. # Manipulate configuration $app->config->{foo} = 'bar'; my $foo = $app->config->{foo}; delete $app->config->{foo}; "handler" $app->handler($tx); 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. sub handler { my ($self, $tx) = @_; ... } SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>. perl v5.14.2 2012-09-05 Mojo(3pm)

Check Out this Related Man Page

ojo(3pm)						User Contributed Perl Documentation						  ojo(3pm)

NAME
ojo - Fun Oneliners with Mojo! SYNOPSIS
$ perl -Mojo -E 'say g("mojolicio.us")->dom->at("title")->text' DESCRIPTION
A collection of automatically exported functions for fun Perl oneliners. Ten redirects will be followed by default, you can change this behavior with the "MOJO_MAX_REDIRECTS" environment variable. $ MOJO_MAX_REDIRECTS=0 perl -Mojo -E 'say g("mojolicio.us")->code' Proxy detection is enabled by default, but you can disable it with the "MOJO_PROXY" environment variable. $ MOJO_PROXY=0 perl -Mojo -E 'say g("mojolicio.us")->body' FUNCTIONS
ojo implements the following functions. "a" my $app = a('/' => sub { shift->render(json => {hello => 'world'}) }); Create a route with "any" in Mojolicious::Lite and return the current Mojolicious::Lite object. See also the Mojolicious::Lite tutorial for more argument variations. $ perl -Mojo -E 'a("/" => {text => "Hello Mojo!"})->start' daemon "b" my $stream = b('lalala'); Turn string into a Mojo::ByteStream object. $ perl -Mojo -E 'b(g("mojolicio.us")->body)->html_unescape->say' "c" my $collection = c(1, 2, 3); Turn list into a Mojo::Collection object. "d" my $res = d('mojolicio.us'); my $res = d('http://mojolicio.us' => {DNT => 1} => 'Hi!'); Perform "DELETE" request with "delete" in Mojo::UserAgent and return resulting Mojo::Message::Response object. "f" my $res = f('http://kraih.com' => {a => 'b'}); my $res = f('kraih.com' => 'UTF-8' => {a => 'b'} => {DNT => 1}); Perform "POST" form request with "post_form" in Mojo::UserAgent and return resulting Mojo::Message::Response object. "g" my $res = g('mojolicio.us'); my $res = g('http://mojolicio.us' => {DNT => 1} => 'Hi!'); Perform "GET" request with "get" in Mojo::UserAgent and return resulting Mojo::Message::Response object. "h" my $res = h('mojolicio.us'); my $res = h('http://mojolicio.us' => {DNT => 1} => 'Hi!'); Perform "HEAD" request with "head" in Mojo::UserAgent and return resulting Mojo::Message::Response object. "o" my $res = o('mojolicio.us'); my $res = o('http://mojolicio.us' => {DNT => 1} => 'Hi!'); Perform "OPTIONS" request with "options" in Mojo::UserAgent and return resulting Mojo::Message::Response object. "p" my $res = p('mojolicio.us'); my $res = p('http://mojolicio.us' => {DNT => 1} => 'Hi!'); Perform "POST" request with "post" in Mojo::UserAgent and return resulting Mojo::Message::Response object. "t" my $res = t('mojolicio.us'); my $res = t('http://mojolicio.us' => {DNT => 1} => 'Hi!'); Perform "PATCH" request with "patch" in Mojo::UserAgent and return resulting Mojo::Message::Response object. "u" my $res = u('mojolicio.us'); my $res = u('http://mojolicio.us' => {DNT => 1} => 'Hi!'); Perform "PUT" request with "put" in Mojo::UserAgent and return resulting Mojo::Message::Response object. "x" my $dom = x('<div>Hello!</div>'); Turn HTML5/XML input into Mojo::DOM object. $ perl -Mojo -E 'say x("<div>Hello!</div>")->at("div")->text' SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>. perl v5.14.2 2012-09-05 ojo(3pm)
Man Page