summaryrefslogtreecommitdiff
path: root/lib/TUWF/Request.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2017-12-09 18:59:04 +0100
committerYorhel <git@yorhel.nl>2017-12-09 18:59:07 +0100
commitf1d83e26ba17cfe60218221863c92de71d9c7eee (patch)
treef41da07e4e5a58a2a7f766596a7ed7db330397aa /lib/TUWF/Request.pm
parentaff3a2174c919da117ae41386dca825910775a36 (diff)
Add sexier replacements for TUWF::register()
Once again inspired by Dancer2. The main improvements over TUWF::register() are: - Support for other HTTP methods than HEAD/GET/POST - HTTP method filtering in the routing code - Differentiate between literal and regex routes - Mandate 'tuwf->capture()' - Include the leading slash, to make it more explicit that it matches the entire path. I've wanted to make that last change back in 55cbbb319a135dbddfbfdd989bc0cb364edef81d, but couldn't because that would break a lot of code. TUWF::register() still works like it used to, so these additions shouldn't break anything.
Diffstat (limited to 'lib/TUWF/Request.pm')
-rw-r--r--lib/TUWF/Request.pm6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/TUWF/Request.pm b/lib/TUWF/Request.pm
index d71cf16..394d950 100644
--- a/lib/TUWF/Request.pm
+++ b/lib/TUWF/Request.pm
@@ -36,13 +36,13 @@ sub reqInit {
die $@ if !$err;
my $meth = $self->reqMethod;
- return 'method' if $meth !~ /^(GET|POST|HEAD)$/;
+ return 'method' if $meth !~ /^(GET|POST|HEAD|DEL|OPTIONS|PUT|PATCH)$/;
- if($meth eq 'POST' && $ENV{CONTENT_LENGTH}) {
+ if($meth =~ /^(POST|PUT|PATCH)$/ && $ENV{CONTENT_LENGTH}) {
return 'maxpost' if $self->{_TUWF}{max_post_body} && $ENV{CONTENT_LENGTH} > $self->{_TUWF}{max_post_body};
my $data;
- die "Couldn't read all POST data.\n" if $ENV{CONTENT_LENGTH} > read STDIN, $data, $ENV{CONTENT_LENGTH}, 0;
+ die "Couldn't read all request data.\n" if $ENV{CONTENT_LENGTH} > read STDIN, $data, $ENV{CONTENT_LENGTH}, 0;
$err = eval {
if(($ENV{'CONTENT_TYPE'}||'') =~ m{^application/json(?:;.*)?$}) {