Is there a way to specify in the builder section of a particular method (GET or POST), but not both at once? My example of builder section.
my $main_app=builder
{
mount "/" => builder{$app;};
};
It handles get and post requests, how can I disable the processing of GET requests?
Thanks.
Plack::Builder does not provide a native way to route requests based on HTTP method. Writing a middleware handling specific methods should be quite simple. For example something like
my $post_app = ...;
my $main = builder {
enable sub {
my $app = shift;
sub {
my $env = shift;
if ($env->{REQUEST_METHOD} eq "POST") {
return $post_app->($env);
}
return $app->($env);
}
};
....;
};
Existing frameworks based om PSGI might provide better alternatives for routing requests based om HTTP method. For example it looks easy to do with Dancer.