The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

HTTP::Server::Simple::Er - lightweight server and interface

SYNOPSIS

  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;

ABOUT

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.

new

  my $server = HTTP::Server::Simple::Er->new(%props);

child_server

Starts the server as a child process.

  my $url = $server->child_server;

handler

You may override this, or simply set req_handler before calling run.

  $server->handler;

output

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);

params

Return a hash of parameters parsed from $self->query_string;

  my %params = $server->params;

form_data

Retrieve POSTed form data. If an element is mentioned twice, its value automatically becomes an arrayref.

  my %form = $server->form_data;

AUTHOR

Eric Wilhelm @ <ewilhelm at cpan dot org>

http://scratchcomputing.com/

BUGS

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

Copyright (C) 2008 Eric L. Wilhelm, All Rights Reserved.

NO WARRANTY

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.

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.