Added ProxyPass ignores for static files. Removed
[catagits/Catalyst-Manual.git] / lib / Catalyst / Manual / Cookbook.pod
index 0aa6dc5..3aed940 100644 (file)
@@ -62,10 +62,11 @@ nifty statistics in your debug messages.
 =head2 Enable debug status in the environment
 
 Normally you enable the debugging info by adding the C<-Debug> flag to
-your C<use Catalyst> statement. However, you can also enable it using
-environment variable, so you can (for example) get debug info without
-modifying your application scripts. Just set C<CATALYST_DEBUG> or
-C<E<lt>MYAPPE<gt>_DEBUG> to a true value.
+your C<use Catalyst> statement (or C<__PACKAGE__->setup(qw/-Debug/)
+). However, you can also enable it using environment variable, so you
+can (for example) get debug info without modifying your application
+scripts. Just set C<CATALYST_DEBUG> or C<E<lt>MYAPPE<gt>_DEBUG> to a
+true value.
 
 =head2 Sessions
 
@@ -112,11 +113,12 @@ reference.
 
 =head3 EXAMPLE
 
-  use Catalyst qw/
-                 Session
-                 Session::Store::FastMmap
-                 Session::State::Cookie
-                 /;
+  use parent qw/Catalyst/;
+  __PACKAGE__->setup( qw/
+                         Session
+                         Session::Store::FastMmap
+                         Session::State::Cookie
+                   /;)
 
 
   ## Write data into the session
@@ -266,12 +268,13 @@ in the previous example.
 The L<Catalyst::Plugin::Authorization::Roles> plugin is required when
 implementing roles:
 
- use Catalyst qw/
-    Authentication
-    Authentication::Credential::Password
-    Authentication::Store::Htpasswd
-    Authorization::Roles
-  /;
+ use parent qw/Catalyst/;
+ __PACKAGE__->setup (qw/
+     Authentication
+     Authentication::Credential::Password
+     Authentication::Store::Htpasswd
+     Authorization::Roles
+  /);
 
 Roles are implemented automatically when using
 L<Catalyst::Authentication::Store::Htpasswd>:
@@ -400,10 +403,11 @@ the user is a member.
 
 =head3 EXAMPLE
 
- use Catalyst qw/Authentication
-                 Authentication::Credential::Password
-                 Authentication::Store::Htpasswd
-                 Authorization::Roles/;
+ use parent qw/Catalyst/;
+ __PACKAGE__->setup( qw/Authentication
+                        Authentication::Credential::Password
+                        Authentication::Store::Htpasswd
+                        Authorization::Roles/);
 
  __PACKAGE__->config->{authentication}{htpasswd} = "passwdfile";
 
@@ -496,10 +500,11 @@ action, so that only a qualified moose feeder can perform that action.
 The Authorization::Roles plugin let's us perform role based access
 control checks. Let's load it:
 
-    use Catalyst qw/
+    use parent qw/Catalyst/;
+    __PACKAGE__->setup(qw/
         Authentication # yadda yadda
         Authorization::Roles
-    /;
+    /);
 
 And now our action should look like this:
 
@@ -713,7 +718,7 @@ later) and SOAP::Lite (for XMLRPCsh.pl).
 
 3. Add the XMLRPC plugin to MyApp.pm
 
-    use Catalyst qw/-Debug Static::Simple XMLRPC/;
+    __PACKAGE__->setup( qw/-Debug Static::Simple XMLRPC/);
 
 4. Add an API controller
 
@@ -1763,7 +1768,7 @@ The development server is a mini web server written in perl.  If you
 expect a low number of hits or you don't need mod_perl/FastCGI speed,
 you could use the development server as the application server with a
 lightweight proxy web server at the front.  However, consider using
-L<Catalyst::Engine::HTTP::POE> for this kind of deployment instead, since
+L<Catalyst::Engine::HTTP::Prefork> for this kind of deployment instead, since
 it can better handle multiple concurrent requests without forking, or can
 prefork a set number of servers for improved performance.
 
@@ -1808,9 +1813,18 @@ Make sure mod_proxy is enabled and add:
         Order deny,allow
         Allow from all
     </Proxy>
+
+    # Need to specifically stop these paths from being passed to proxy
+    ProxyPass /static !
+    ProxyPass /favicon.ico !
+
     ProxyPass / http://localhost:8080/
     ProxyPassReverse / http://localhost:8080/
 
+    # This is optional if you'd like to show a custom error page 
+    # if the proxy is not available
+    ErrorDocument 502 /static/error_pages/http502.html
+
 You can wrap the above within a VirtualHost container if you want
 different apps served on the same host.
 
@@ -1898,7 +1912,7 @@ B<root/images/me.jpg> is found and served.
 
 Using the plugin is as simple as setting your use line in MyApp.pm to include:
 
- use Catalyst qw/Static::Simple/;
+ __PACKAGE__->setup( qw/Static::Simple/);
 
 and already files will be served.
 
@@ -1983,7 +1997,7 @@ using L<Catalyst::Plugin::Static>.
 
 In your main application class (MyApp.pm), load the plugin:
 
-    use Catalyst qw/-Debug FormValidator Static OtherPlugin/;
+    __PACKAGE__->setup( qw/-Debug FormValidator Static OtherPlugin/);
 
 You will also need to make sure your end method does I<not> forward
 static content to the view, perhaps like this:
@@ -2093,12 +2107,12 @@ There are three wrapper plugins around common CPAN cache modules:
 Cache::FastMmap, Cache::FileCache, and Cache::Memcached.  These can be
 used to cache the result of slow operations.
 
-This very page you're viewing makes use of the FileCache plugin to cache the
+The Catalyst Advent Calendar uses the FileCache plugin to cache the
 rendered XHTML version of the source POD document.  This is an ideal
-application for a cache because the source document changes infrequently but
-may be viewed many times.
+application for a cache because the source document changes
+infrequently but may be viewed many times.
 
-    use Catalyst qw/Cache::FileCache/;
+    __PACKAGE__->setup( qw/Cache::FileCache/);
     
     ...
     
@@ -2146,7 +2160,7 @@ thing for every single user who views the page.
 
 We can add the PageCache plugin to speed things up.
 
-    use Catalyst qw/Cache::FileCache PageCache/;
+    __PACKAGE__->setup( qw/Cache::FileCache PageCache/);
     
     sub front_page : Path ('/') {
         my ( $self, $c ) = @_;