Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added Web::Simple

  • Loading branch information...
commit c296d7d576dde69bab0483731c808f98cb281443 1 parent 7cca271
@miyagawa authored
Showing with 37 additions and 0 deletions.
  1. +37 −0 web-simple.pl
View
37 web-simple.pl
@@ -0,0 +1,37 @@
+use Web::Simple 'TestApp';
+
+package TestApp;
+use Plack::Request;
+use Plack::Response;
+
+dispatch {
+ sub (GET + /) {
+ my $res = Plack::Response->new(200);
+ $res->content_type('text/plain');
+ $res->content("Hello World");
+ $res->finalize;
+ },
+
+ sub (GET + /blog/*/*) {
+ my($self, $year, $month) = @_;
+ my $res = Plack::Response->new(200);
+ $res->content_type('text/html');
+ $res->content("Blog posts from $year/$month");
+ $res->finalize;
+ },
+
+ sub (POST + /comment + %*) {
+ my($self, $params) = @_;
+ my $res = Plack::Response->new(200);
+ $res->content_type('text/plain');
+ $res->content("Comment posted with body=" . $params->{body});
+ $res->finalize;
+ },
+
+ sub (GET) {
+ Plack::Response->new(404)->finalize;
+ }
+};
+
+TestApp->as_psgi_app;
+
Please sign in to comment.
Something went wrong with that request. Please try again.