HTTP::Server::Simple::Er - lightweight server and interface
use HTTP::Server::Simple::Er; HTTP::Server::Simple::Er->new(port => 8089, req_handler => sub { my $self = shift; my $path = $self->path; ... $self->output(404, "can't find it"); } )->run;
This is mostly an API experiment. You might be perfectly happy with HTTP::Server::Simple, but I find that I often want to use it only in tests and that the interface is a little clunky for that, so I'm gathering some of the handiness that has been sitting on my hard drive and starting to get it on CPAN.
my $server = HTTP::Server::Simple::Er->new(%props);
Starts the server as a child process.
my $url = $server->child_server;
You may override this, or simply set req_handler before calling run.
req_handler
$server->handler;
Takes status code from $params{status} or a leading number. Otherwise, sets it to 200.
$self->output(\%params, @strings); $self->output(501, \%params, @strings); $self->output(501, @strings); $self->output(@strings);
The code may also be an 'RC_*' string which corresponds to a constant from HTTP::Status.
$self->output(RC_NOT_FOUND => @error_html);
Return a hash of parameters parsed from $self->query_string;
my %params = $server->params;
Retrieve POSTed form data. If an element is mentioned twice, its value automatically becomes an arrayref.
my %form = $server->form_data;
Eric Wilhelm @ <ewilhelm at cpan dot org>
http://scratchcomputing.com/
If you found this module on CPAN, please report any bugs or feature requests through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
If you pulled this development version from my /svn/, please contact me directly.
Copyright (C) 2008 Eric L. Wilhelm, All Rights Reserved.
Absolutely, positively NO WARRANTY, neither express or implied, is offered with this software. You use this software at your own risk. In case of loss, no person or entity owes you anything whatsoever. You have been warned.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install HTTP::Server::Simple::Er, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTTP::Server::Simple::Er
CPAN shell
perl -MCPAN -e shell install HTTP::Server::Simple::Er
For more information on module installation, please visit the detailed CPAN module installation guide.