requires 'match', 'match_captures', 'list_extra_info';
-around ['match','match_captures'] => sub {
- my ($orig, $self, $ctx, @args) = @_;
- my $expected = $self->_normalize_expected_http_method($ctx->req);
- return $self->_has_expected_http_method($expected) ?
- $self->$orig($ctx, @args) :
- 0;
-};
-
-sub _normalize_expected_http_method {
- my ($self, $req) = @_;
- return $req->header('X-HTTP-Method') ||
- $req->header('X-HTTP-Method-Override') ||
- $req->header('X-METHOD-OVERRIDE') ||
- $req->method;
-}
+sub allowed_http_methods { @{shift->attributes->{Method}||[]} }
sub _has_expected_http_method {
my ($self, $expected) = @_;
1 : 0;
}
-sub allowed_http_methods { @{shift->attributes->{Method}||[]} }
+around ['match','match_captures'] => sub {
+ my ($orig, $self, $ctx, @args) = @_;
+ return 0 unless $self->$orig($ctx, @args);
+
+ my $expected = $ctx->req->method;
+ return $self->_has_expected_http_method($expected);
+};
around 'list_extra_info' => sub {
my ($orig, $self, @args) = @_;
sub user_base : Chained('/') CaptureArg(0) { ... }
- sub get_user : Chained('user_base') Args(1) GET { ... }
- sub post_user : Chained('user_base') Args(1) POST { ... }
- sub put_user : Chained('user_base') Args(1) PUT { ... }
- sub delete_user : Chained('user_base') Args(1) DELETE { ... }
- sub head_user : Chained('user_base') Args(1) HEAD { ... }
- sub option_user : Chained('user_base') Args(1) OPTION { ... }
- sub option_user : Chained('user_base') Args(1) PATCH { ... }
+ sub get_user : Chained('user_base') Args(1) GET { ... }
+ sub post_user : Chained('user_base') Args(1) POST { ... }
+ sub put_user : Chained('user_base') Args(1) PUT { ... }
+ sub delete_user : Chained('user_base') Args(1) DELETE { ... }
+ sub head_user : Chained('user_base') Args(1) HEAD { ... }
+ sub options_user : Chained('user_base') Args(1) OPTIONS { ... }
+ sub patch_user : Chained('user_base') Args(1) PATCH { ... }
sub post_and_put : Chained('user_base') POST PUT Args(1) { ... }
HTTP methods, such as GET, POST, etc.
Since most web browsers have limited support for rich HTTP Method vocabularies
-we also support setting the expected match method via the follow non standard
-but widely used http extensions. Our support for these should not be taken as
-an endorsement of the technique. Rt is merely a reflection of our desire to
-work well with existing systems and common client side tools.
-
-=over 4
-
-=item X-HTTP-Method (Microsoft)
-
-=item X-HTTP-Method-Override (Google/GData)
-
-=item X-METHOD-OVERRIDE (IBM)
-
-=back
-
-Please note the insanity of overriding a GET request with a DELETE override...
-Rational practices suggest that using POST with overrides to emulate PUT and
-DELETE can be an acceptable way to deal with client limitations and security
-rules on your proxy server. I recommend going no further.
+we use L<Plack::Middleware::MethodOverride> which allows you to 'tunnel' your
+request method over POST This works in two ways. You can set an extension
+HTTP header C<X-HTTP-Method-Override> which will contain the value of the
+desired request method, or you may set a search query parameter
+C<x-tunneled-method>. Remember, these only work over HTTP Request type
+POST. See L<Plack::Middleware::MethodOverride> for more.
=head1 REQUIRES