1Mojo::Server::CGI(3) User Contributed Perl Documentation Mojo::Server::CGI(3)
2
3
4
6 Mojo::Server::CGI - CGI server
7
9 use Mojo::Server::CGI;
10
11 my $cgi = Mojo::Server::CGI->new;
12 $cgi->unsubscribe('request')->on(request => sub {
13 my ($cgi, $tx) = @_;
14
15 # Request
16 my $method = $tx->req->method;
17 my $path = $tx->req->url->path;
18
19 # Response
20 $tx->res->code(200);
21 $tx->res->headers->content_type('text/plain');
22 $tx->res->body("$method request for $path!");
23
24 # Resume transaction
25 $tx->resume;
26 });
27 $cgi->run;
28
30 Mojo::Server::CGI is a simple and portable implementation of RFC 3875
31 <http://tools.ietf.org/html/rfc3875>.
32
33 See "DEPLOYMENT" in Mojolicious::Guides::Cookbook for more.
34
36 Mojo::Server::CGI inherits all events from Mojo::Server.
37
39 Mojo::Server::CGI inherits all attributes from Mojo::Server and
40 implements the following new ones.
41
42 nph
43 my $bool = $cgi->nph;
44 $cgi = $cgi->nph($bool);
45
46 Activate non-parsed header mode.
47
49 Mojo::Server::CGI inherits all methods from Mojo::Server and implements
50 the following new ones.
51
52 run
53 my $status = $cgi->run;
54
55 Run CGI.
56
58 Mojolicious, Mojolicious::Guides, <https://mojolicious.org>.
59
60
61
62perl v5.28.0 2018-05-08 Mojo::Server::CGI(3)