[$url, $handler], ... ]; my $CALLBACK = {}; sub import { my $pkg = shift; my @args = @_; my $callpkg = caller(0); for my $method (qw(get post put del)) { $CALLBACK->{$callpkg}->{$method} = []; } # sub handler definition require Apache2::RequestRec; require Apache2::RequestUtil; require APR::Table; no strict 'refs'; *{"$callpkg\::handler"} = \&import_handler; for my $method (qw(get post put del)) { *{"$callpkg\::$method"} = sub { my ($url, $handler) = @_; push @{$CALLBACK->{$callpkg}->{$method}}, [$url, $handler]; }; } *{"$callpkg\::default"} = sub { my $handler = shift; $CALLBACK->{$callpkg} ||= {}; $CALLBACK->{$callpkg}->{default} = $handler; }; }