Permalink
Browse files

added engine example

  • Loading branch information...
1 parent ffaae74 commit f1185114e1291dcaadc16d1b513ddbf6be76ac7a @dann committed Oct 2, 2009
Showing with 37 additions and 3 deletions.
  1. +32 −0 examples/example.pl
  2. +5 −3 {config → examples}/example.psgi
View
@@ -0,0 +1,32 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use PlackX::Engine;
+use Plack::Response;
+
+my $request_handler = sub {
+ my $req = shift;
+ my $res = Plack::Response->new;
+ $res->code(200);
+ $res->header( 'Content-Type' => 'text/html' );
+ $res->body("Hello World");
+ return $res;
+};
+
+my $engine = PlackX::Engine->new(
+ { server => {
+ module => 'ServerSimple',
+ args => {
+ port => 3000,
+ host => 'localhost',
+ },
+ },
+ request_handler => $request_handler,
+ middlewares => [
+ { module => "Plack::Middleware::AccessLog::Timed" },
+ { module => "Plack::Middleware::Static" }
+ ],
+ }
+);
+
+my $handler = $engine->run;
@@ -6,7 +6,7 @@ my $request_handler = sub {
my $res = Plack::Response->new;
$res->code(200);
$res->header( 'Content-Type' => 'text/html' );
- $res->body( "Hello World" );
+ $res->body("Hello World");
return $res;
};
@@ -19,8 +19,10 @@ my $engine = PlackX::Engine->new(
},
},
request_handler => $request_handler,
- middlewares =>
- [ { module => "Plack::Middleware::AccessLog::Timed" }, { module => "Plack::Middleware::Static" } ],
+ middlewares => [
+ { module => "Plack::Middleware::AccessLog::Timed" },
+ { module => "Plack::Middleware::Static" }
+ ],
}
);

0 comments on commit f118511

Please sign in to comment.