bump version
[catagits/Web-Simple.git] / examples / dispatchex / dispatchex.cgi
1 use Web::Simple 'DispatchEx';
2
3 package DispatchEx;
4
5 dispatch {
6   response_filter {
7     [ 200, [ 'Content-type' => 'text/plain' ], $_[1] ];
8   },
9   subdispatch sub (.html) {
10     [
11       response_filter { [ @{$_[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
29 DispatchEx->run_if_script;