CGI::A...Server(3pm)

πŸ“¦
version 0.063 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– CGI::Application::Server πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation and it's all about CGI::Application::Server, which β€” ngl β€” is literally the cutest lil HTTP server for when you're out here developing with CGI::Application. no cap. let's get into it 🫢


✨ NAME ✨

CGI::Application::Server β€” a simple HTTP server for developing with CGI::Application πŸ’…


🌸 VERSION 🌸

version 0.063 ✨


πŸŽ€ SYNOPSIS πŸŽ€

look at this gorgeous little setup, she's giving main character energy:

use CGI::Application::Server;
use MyCGIApp;
use MyCGIApp::Admin;
use MyCGI::App::Account::Dispatch;
use MyCGIApp::DefaultApp;

my $server = CGI::Application::Server->new();

# this CGI::Application object will stay persistent, might not be safe to use
# in this way - your mileage may vary
# http://www.mail-archive.com/cgiapp@lists.erlbaum.net/msg08997.html
my $object = MyOtherCGIApp->new(PARAMS => { foo => 1, bar => 2 });

$server->document_root('./htdocs');
$server->entry_points({
    '/'          => 'MyCGIApp::DefaultApp',
    '/index.cgi' => 'MyCGIApp',
    '/admin'     => 'MyCGIApp::Admin',
    '/account'   => 'MyCGIApp::Account::Dispatch',
    '/users'     => $object,
    '/static'    => '/usr/local/htdocs',
});
$server->run();
heads up babe: that $object up there stays persistent, and apparently that might not be safe to use that way β€” your mileage may vary πŸ™ˆ

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically? this is a simple HTTP server meant for use during development with CGI::Application. at this moment, it serves our needs in a very basic way β€” and honestly, that's the vibe. the plan is to release early and release often, and add features when we need them. periodt. πŸ’…

that said, we welcome any and all patches, tests and feature requests πŸ₯Ί and the ones that come with failing tests? they get priority. no cap. πŸ”₯


πŸ‘‘ METHODS πŸ‘‘

πŸ’œ new ($port)

this acts just like "new" for HTTP::Server::Simple, except it will also initialize the instance slots that we use. so it's new but ✨extra✨.

🌈 handle_request

this will check the request uri and dispatch appropriately β€” either to an entry point, or serve a static file (html, jpeg, gif, etc). she does it all, fr fr.

πŸ“ entry_points (?$entry_points)

this accepts a HASH reference in $entry_points, which maps server entry points (uri) to CGI::Application or CGI::Application::Dispatch class names or objects, or to directories from which static content will be served by HTTP::Server::Simple::Static. peek the SYNOPSIS above for examples, iykyk πŸ‘€

🧚 is_valid_entry_point ($uri)

this attempts to match the $uri to an entry point. vibe check for uris, essentially πŸ’€

⭐ document_root (?$document_root)

this is the server's document root β€” where all the static files will be served from. her home base, her safe space 🏠


πŸ’€ CAVEATS πŸ’€

this is a subclass of HTTP::Server::Simple, and all of its caveats apply here as well. not me inheriting all the baggage too 😭


πŸŽ€ ACKNOWLEDGEMENTS πŸŽ€

the HTTP response handling was shamelessly stolen from HTTP::Request::AsCGI by chansen. iconic behaviour, honestly. ate. πŸ’…


🫢 AUTHORS 🫢

  • Stevan Little <stevan@iinteractive.com>
  • Rob Kinyon <rob.kinyon@iinteractive.com>
  • Ricardo SIGNES <rjbs@cpan.org>

this software is copyright (c) 2006 by Infinity Interactive, Inc.

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. slay. 🌈


and that's the whole page bestie!! this manual page came to you courtesy of perl v5.32.0, dated 2020-11-09, and yeah β€” the manual name is CGI::A...Server(3pm), all folded up nicely like we said πŸŽ€ mwah, go write some CGI::Application code, you got this πŸ’œβœ¨

πŸ“¦ where this page comes from