our @EXPORT = qw(
match_and match_or match_not match_method match_path match_path_strip
- match_extension match_query match_body
+ match_extension match_query match_body match_uploads
);
sub match_and {
}
sub match_query {
- my $spec = shift;
- require Web::Dispatch::ParamParser;
- sub {
- _extract_params(
- Web::Dispatch::ParamParser::get_unpacked_query_from($_[0]),
- $spec
- )
- };
+ _param_matcher(query => $_[0]);
}
sub match_body {
- my $spec = shift;
+ _param_matcher(body => $_[0]);
+}
+
+sub match_uploads {
+ _param_matcher(uploads => $_[0]);
+}
+
+sub _param_matcher {
+ my ($type, $spec) = @_;
require Web::Dispatch::ParamParser;
+ my $unpack = Web::Dispatch::ParamParser->can("get_unpacked_${type}_from");
sub {
- _extract_params(
- Web::Dispatch::ParamParser::get_unpacked_body_from($_[0]),
- $spec
- )
+ _extract_params($unpack->($_[0]), $spec)
};
}