Skip to content

Commit

Permalink
Added Web::Simple
Browse files Browse the repository at this point in the history
  • Loading branch information
miyagawa committed Mar 16, 2010
1 parent 7cca271 commit c296d7d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions 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;

0 comments on commit c296d7d

Please sign in to comment.