Subject: | Wish on the doc |
Date: | Tue, 15 Jul 2008 18:13:34 +0200 |
To: | bug-HTTP-Server-Simple-Static [...] rt.cpan.org |
From: | Samuel GRANJEAUD - IR/ICIM <granjeau [...] tagc.univ-mrs.fr> |
Hello !
To add the serve_static function, I feel that an example could be
useful. To my opinion, because the simple server is used to implement
CGI, it should look like (borrowed from HTTP::Server::Simple):
sub handle_request {
my $self = shift;
my $cgi = shift;
my $path = $cgi->path_info();
my $handler = $dispatch{$path};
if (ref($handler) eq "CODE") {
print "HTTP/1.0 200 OK\r\n";
$handler->($cgi);
} elsif (!$self->serve_static( $cgi, $webroot )) {
print "HTTP/1.0 404 Not found\r\n";
print $cgi->header,
$cgi->start_html('Not found'),
$cgi->h1('Not found'),
$cgi->end_html;
}
}
$webroot should also be defined somewhere.
It should be nice to have a link to HTTP::Server::Simple in the See also
section.
Best regards.
PS: do not forget to close patch once implemented.