fix RT#42025 by making C::Request::REST less unfriendly
[catagits/Catalyst-Action-REST.git] / lib / Catalyst / Request / REST.pm
index 447680e..795614c 100644 (file)
@@ -13,6 +13,17 @@ use warnings;
 use base qw/Catalyst::Request Class::Accessor::Fast/;
 use HTTP::Headers::Util qw(split_header_words);
 
+sub _insert_self_into {
+  my ($class, $app) = @_;
+  my $req_class = $app->request_class;
+  return if $req_class->isa($class);
+  if ($req_class eq 'Catalyst::Request') {
+    $app->request_class($class);
+  } else {
+    die "$app has a custom request class $req_class, "
+      . "which is not a $class; see Catalyst::Request::REST";
+  }
+}
 
 =head1 NAME
 
@@ -32,6 +43,11 @@ This is a subclass of C<Catalyst::Request> that adds a few methods to
 the request object to faciliate writing REST-y code. Currently, these
 methods are all related to the content types accepted by the client.
 
+Note that if you have a custom request class in your application, and it does
+not inherit from C<Catalyst::Request::REST>, your application will fail with an
+error indicating a conflict the first time it tries to use
+C<Catalyst::Request::REST>'s functionality.  To fix this error, make sure your
+custom request class inherits from C<Catalyst::Request::REST>.
 
 =head1 METHODS