PageRenderTime 27ms CodeModel.GetById 12ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 1ms

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