1Mojo::Server::PSGI(3) User Contributed Perl DocumentationMojo::Server::PSGI(3)
2
3
4
6 Mojo::Server::PSGI - PSGI server
7
9 use Mojo::Server::PSGI;
10
11 my $psgi = Mojo::Server::PSGI->new;
12 $psgi->unsubscribe('request')->on(request => sub {
13 my ($psgi, $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 my $app = $psgi->to_psgi_app;
28
30 Mojo::Server::PSGI allows Mojolicious applications to run on all PSGI
31 compatible servers.
32
33 See "DEPLOYMENT" in Mojolicious::Guides::Cookbook for more.
34
36 Mojo::Server::PSGI inherits all events from Mojo::Server.
37
39 Mojo::Server::PSGI inherits all attributes from Mojo::Server.
40
42 Mojo::Server::PSGI inherits all methods from Mojo::Server and
43 implements the following new ones.
44
45 run
46 my $res = $psgi->run($env);
47
48 Run PSGI.
49
50 to_psgi_app
51 my $app = $psgi->to_psgi_app;
52
53 Turn Mojolicious application into PSGI application.
54
56 Mojolicious, Mojolicious::Guides, <https://mojolicious.org>.
57
58
59
60perl v5.32.0 2020-07-28 Mojo::Server::PSGI(3)