1CGI::Application::ServeUrs(e3r)Contributed Perl DocumentCaGtIi:o:nApplication::Server(3)
2
3
4
6 CGI::Application::Server - a simple HTTP server for developing with
7 CGI::Application
8
10 version 0.063
11
13 use CGI::Application::Server;
14 use MyCGIApp;
15 use MyCGIApp::Admin;
16 use MyCGI::App::Account::Dispatch;
17 use MyCGIApp::DefaultApp;
18
19 my $server = CGI::Application::Server->new();
20
21 # this CGI::Application object will stay persistent, might not be safe to use
22 # in this way - your mileage may vary
23 # http://www.mail-archive.com/cgiapp@lists.erlbaum.net/msg08997.html
24 my $object = MyOtherCGIApp->new(PARAMS => { foo => 1, bar => 2 });
25
26 $server->document_root('./htdocs');
27 $server->entry_points({
28 '/' => 'MyCGIApp::DefaultApp',
29 '/index.cgi' => 'MyCGIApp',
30 '/admin' => 'MyCGIApp::Admin',
31 '/account' => 'MyCGIApp::Account::Dispatch',
32 '/users' => $object,
33 '/static' => '/usr/local/htdocs',
34 });
35 $server->run();
36
38 This is a simple HTTP server for for use during development with
39 CGI::Application. At this moment, it serves our needs in a very basic
40 way. The plan is to release early and release often, and add features
41 when we need them. That said, we welcome any and all patches, tests and
42 feature requests (the ones with which are accompanied by failing tests
43 will get priority).
44
46 new ($port)
47 This acts just like "new" for HTTP::Server::Simple, except it will
48 initialize instance slots that we use.
49
50 handle_request
51 This will check the request uri and dispatch appropriately, either to
52 an entry point, or serve a static file (html, jpeg, gif, etc).
53
54 entry_points (?$entry_points)
55 This accepts a HASH reference in $entry_points, which maps server entry
56 points (uri) to CGI::Application or CGI::Application::Dispatch class
57 names or objects or to directories from which static content will be
58 served by HTTP::Server::Simple::Static. See the SYNOPSIS above for
59 examples.
60
61 is_valid_entry_point ($uri)
62 This attempts to match the $uri to an entry point.
63
64 document_root (?$document_root)
65 This is the server's document root where all static files will be
66 served from.
67
69 This is a subclass of HTTP::Server::Simple and all of its caveats apply
70 here as well.
71
73 The HTTP response handling was shamelessly stolen from
74 HTTP::Request::AsCGI by chansen
75
77 · Stevan Little <stevan@iinteractive.com>
78
79 · Rob Kinyon <rob.kinyon@iinteractive.com>
80
81 · Ricardo SIGNES <rjbs@cpan.org>
82
84 This software is copyright (c) 2006 by Infinity Interactive, Inc.
85
86 This is free software; you can redistribute it and/or modify it under
87 the same terms as the Perl 5 programming language system itself.
88
89
90
91perl v5.32.0 2020-07-28 CGI::Application::Server(3)