POD cleanup, extended warning and changes section
[catagits/Web-Simple.git] / examples / dispatchex / dispatchex.cgi
CommitLineData
795c4698 1use Web::Simple 'DispatchEx';
2
3package DispatchEx;
4
5dispatch [
6 filter_response {
7 [ 200, [ 'Content-type' => 'text/plain' ], $_[1] ];
8 },
9 subdispatch sub (.html) {
10 [
11 filter_response { [ @{$_[1]}, '.html' ] },
12 sub (/foo) { [ '/foo' ] },
13 ]
14 },
15 subdispatch sub (/domain/*/...) {
16 return unless (my $domain_id = $_[1]) =~ /^\d+$/;
17 [
18 sub (/) {
19 [ "Domain ${domain_id}" ]
20 },
21 sub (/user/*) {
22 return unless (my $user_id = $_[1]) =~ /^\d+$/;
23 [ "Domain ${domain_id} user ${user_id}" ]
24 }
25 ]
26 }
27];
28
29DispatchEx->run_if_script;