Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: b73aebe42e
Fetching contributors…

Cannot retrieve contributors at this time

49 lines (29 sloc) 1.299 kB
SCGI for Perl 6
-----------------
This is a simple SCGI library for Perl 6.
It's main influences are the Perl 5 SCGI library, and the
Perl 6 HTTP::Daemon library.
It offers a bit of candy coating compared to the Perl 5 version.
The environment contains three special keys:
Request.Body is the request body (usually from an HTTP POST.)
Request.Object is a reference to the individual request object.
Request.SCGI is a reference to the SCGI object itself.
Also, you don't need to create your own IO::Socket::INET object.
Just pass an 'addr' and 'port' attribute to the new() declaration and it'll
create the object for you.
Oh yeah, and instead of using the while loop as shown on the Perl 5 SCGI
documentation, there is a convenience method called 'handle' that does
the heavy lifting for you:
use SCGI;
my $scgi = SCGI.new( :addr<localhost> :port(8080) );
my $handler = sub (%env) {
my $name = %env<QUERY_STRING> // 'world';
my $response = "Content-Type: text/plain\n\n";
$response ~= "Hello $name\n";
return $return;
}
$scgi.handle: $handler;
The output of the handler will be sent as the SCGI response,
so make it a valid CGI response.
Author: Timothy Totten (supernovus) <2010@huri.net> http://huri.net/
Released under the Artisitc License 2.0
Jump to Line
Something went wrong with that request. Please try again.