/examples/poe-dumper.pl

http://github.com/http-engine/HTTP-Engine · Perl · 41 lines · 36 code · 5 blank · 0 comment · 0 complexity · 331db0803e2621a70d2da4d546d583d1 MD5 · raw file

  1. use strict;
  2. use warnings;
  3. use lib 'lib';
  4. use Data::Dumper;
  5. use HTTP::Engine;
  6. use HTTP::Engine::Interface::POE;
  7. use HTTP::Response;
  8. use HTTP::Engine::Request;
  9. use String::TT qw/strip tt/;
  10. my $engine = HTTP::Engine->new(
  11. interface => HTTP::Engine::Interface::POE->new({
  12. port => 3999,
  13. request_handler => sub {
  14. my $req = shift;
  15. local $Data::Dumper::Sortkeys = 1;
  16. my $req_dump = Dumper( $req );
  17. my $raw = $req->raw_body;
  18. my $body = strip tt q{
  19. <form method="post">
  20. <input type="text" name="foo" />
  21. <input type="submit" />
  22. </form>
  23. <form method="post" enctype="multipart/form-data">
  24. <input type="file" name="upload_file" />
  25. <input type="submit" />
  26. </form>
  27. <pre>[% raw | html %]</pre>
  28. <pre>[% req_dump | html %]</pre>
  29. };
  30. HTTP::Engine::Response->new( body => $body );
  31. },
  32. }),
  33. );
  34. $engine->run;
  35. print "Running POE in http://localhost:3999/\n";
  36. POE::Kernel->run;