Mojo::...FastCGI(3pm)
π Mojo::Server::FastCGI β the FastCGI Server page, but make it cute π
okay bestie, welcome to the Mojo::...FastCGI(3pm) page from the User Contributed Perl Documentation π
this is where the FastCGI server lives, and we're gonna go through the whole thing together, no skips, no skimming, because you deserve the full lore πΈ
β¨ NAME β¨
Mojo::Server::FastCGI β it's a FastCGI Server π¦
β¨ SYNOPSIS β¨
here's the whole vibe, copy-paste ready:
use Mojo::Server::FastCGI;
my $fcgi = Mojo::Server::FastCGI->new;
$fcgi->on_request(sub {
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;
});
$fcgi->run;
likeβ¦ the whole server is just vibes and one callback, we love that for us π
β¨ DESCRIPTION β¨
Mojo::Server::FastCGI is a portable pure-Perl FastCGI implementation β¨ exactly as described in the "FastCGI Specification". pure Perl, no weird native deps, we're thriving π§
and if you're like "okay but how do I actually deploy this bestie", go peek at Mojolicious::Guides::Cookbook β it's got the deployment recipes π
β¨ ATTRIBUTES β¨
Mojo::Server::FastCGI inherits all attributes from Mojo::Server. yes, all of them, it's giving nepo baby but in the good way π
β¨ METHODS β¨
Mojo::Server::FastCGI inherits all methods from Mojo::Server, and then it implements these shiny new ones π
accept_connection
my $c = $fcgi->accept_connection;
accepts a FastCGI connection π«Ά like come in, sit down, we've been expecting you
read_record
my ($type, $id, $body) = $fcgi->read_record($c);
parses a FastCGI record π three things come back: $type, $id, and $body
read_request
my $tx = $fcgi->read_request($c);
parses a FastCGI request πΈ and hands you back a $tx
role_name
my $name = $fcgi->role_name(3);
gives you the FastCGI role name π«
role_number
my $number = $fcgi->role_number('FILTER');
gives you the FastCGI role number β feed it a name like 'FILTER', get the number π’
run
$fcgi->run;
starts FastCGI π the main character moment, periodt
type_name
my $name = $fcgi->type_name(5);
gives you the FastCGI type name π
type_number
my $number = $fcgi->type_number('STDIN');
gives you the FastCGI type number β pass in something like 'STDIN', get the number π’
write_records
$fcgi->write_record($c, 'STDOUT', $id, 'HTTP/1.1 200 OK');
writes a FastCGI record βοΈ (yes, the heading says write_records and the call says write_record β that's just how the original rolls, we don't question the icon π)
write_response
$fcgi->write_response($tx);
writes a FastCGI response π
β¨ DEBUGGING β¨
want the tea? β set the MOJO_FASTCGI_DEBUG environment variable and you'll get some advanced diagnostics information sent to the Mojo logger as debug messages π
MOJO_FASTCGI_DEBUG=1
ngl this is the move when something's acting up and you need to see what's actually happening π
β¨ SEE ALSO β¨
MojoliciousMojolicious::Guides- <http://mojolicio.us> π
and that's the whole page bestie π go forth and FastCGI responsibly π
perl v5.34.0 Β· 2022-06-15 β mwah, love u, bye π«Άβ¨
π¦ where this page comes from
- debian bookworm: libmojo-server-fastcgi-perl 0.50-2 Β· Artistic-2.0
- debian trixie: libmojo-server-fastcgi-perl 0.50-2 Β· Artistic-2.0
- ubuntu noble: libmojo-server-fastcgi-perl 0.50-2 Β· Artistic-2.0
- ubuntu resolute: libmojo-server-fastcgi-perl 0.50-2 Β· Artistic-2.0
- ubuntu stonking: libmojo-server-fastcgi-perl 0.50-2 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms