1ojo(3) User Contributed Perl Documentation ojo(3)
2
3
4
6 ojo - Fun Oneliners With Mojo!
7
9 perl -Mojo -e 'b(g("mojolicio.us")->dom->at("title")->text)->say'
10
12 A collection of automatically exported functions for fun Perl
13 oneliners. Note that this module is EXPERIMENTAL and might change
14 without warning!
15
17 ojo implements the following functions.
18
19 "a"
20 my $app = a('/' => sub { shift->render(json => {hello => 'world'}) });
21
22 Create a Mojolicious::Lite route accepting all request methods and
23 return the application.
24
25 perl -Mojo -e 'a("/" => {text => "Hello Mojo!"})->start' daemon
26
27 "b"
28 my $stream = b('lalala');
29
30 Turn input into a Mojo::ByteStream object.
31
32 perl -Mojo -e 'b(g("mojolicio.us")->body)->html_unescape->say'
33
34 "d"
35 my $res = d('http://mojolicio.us');
36 my $res = d('http://mojolicio.us', {'X-Bender' => 'X_x'});
37 my $res = d(
38 'http://mojolicio.us',
39 {'Content-Type' => 'text/plain'},
40 'Hello!'
41 );
42
43 Perform "DELETE" request and turn response into a
44 Mojo::Message::Response object.
45
46 "f"
47 my $res = f('http://kraih.com/foo' => {test => 123});
48 my $res = f('http://kraih.com/foo', 'UTF-8', {test => 123});
49 my $res = f(
50 'http://kraih.com/foo',
51 {test => 123},
52 {'Content-Type' => 'multipart/form-data'}
53 );
54 my $res = f(
55 'http://kraih.com/foo',
56 'UTF-8',
57 {test => 123},
58 {'Content-Type' => 'multipart/form-data'}
59 );
60 my $res = f('http://kraih.com/foo', {file => {file => '/foo/bar.txt'}});
61 my $res = f('http://kraih.com/foo', {file => {content => 'lalala'}});
62 my $res = f(
63 'http://kraih.com/foo',
64 {myzip => {file => $asset, filename => 'foo.zip'}}
65 );
66
67 Perform a "POST" request for a form and turn response into a
68 Mojo::Message::Response object.
69
70 "g"
71 my $res = g('http://mojolicio.us');
72 my $res = g('http://mojolicio.us', {'X-Bender' => 'X_x'});
73 my $res = g(
74 'http://mojolicio.us',
75 {'Content-Type' => 'text/plain'},
76 'Hello!'
77 );
78
79 Perform "GET" request and turn response into a Mojo::Message::Response
80 object. One redirect will be followed by default, you can change this
81 behavior with the "MOJO_MAX_REDIRECTS" environment variable.
82
83 MOJO_MAX_REDIRECTS=0 perl -Mojo -e 'b(g("mojolicious.org")->code)->say'
84
85 "p"
86 my $res = p('http://mojolicio.us');
87 my $res = p('http://mojolicio.us', {'X-Bender' => 'X_x'});
88 my $res = p(
89 'http://mojolicio.us',
90 {'Content-Type' => 'text/plain'},
91 'Hello!'
92 );
93
94 Perform "POST" request and turn response into a Mojo::Message::Response
95 object.
96
97 "u"
98 my $res = u('http://mojolicio.us');
99 my $res = u('http://mojolicio.us', {'X-Bender' => 'X_x'});
100 my $res = u(
101 'http://mojolicio.us',
102 {'Content-Type' => 'text/plain'},
103 'Hello!'
104 );
105
106 Perform "PUT" request and turn response into a Mojo::Message::Response
107 object.
108
109 "w"
110 w('ws://mojolicio.us' => sub {...});
111
112 Open a WebSocket connection.
113
115 Mojolicious, Mojolicious::Guides, <http://mojolicious.org>.
116
117
118
119perl v5.12.3 2010-08-12 ojo(3)