our @EXPORT = qw(
match_and match_or match_not match_method match_path match_path_strip
- match_extension
+ match_extension match_query match_body match_uploads
);
sub match_and {
};
}
+sub match_query {
+ _param_matcher(query => $_[0]);
+}
+
+sub match_body {
+ _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($unpack->($_[0]), $spec)
+ };
+}
+
sub _extract_params {
my ($raw, $spec) = @_;
foreach my $name (@{$spec->{required}||[]}) {