Note apply_default_middlewares method method
[catagits/Catalyst-Runtime.git] / lib / Catalyst / PSGI.pod
CommitLineData
ae908e7e 1=pod
2
3=head1 Catalyst and PSGI
4
5Catalyst used to contain a whole set of C<< Catalyst::Engine::XXXX >> classes to
6adapt to various different web servers, and environments (e.g. CGI, FastCGI, mod_perl)
7etc.
8
9This has been changed so that all of that work is done by Catalyst just implementing
10the L<PSGI> specification, and using L<Plack>'s adaptors to implement that functionality.
11
12This means that we can share common code, and fixes for specific web servers.
13
14=head1 I already have an application
15
16If you already have a Catalyst application, then this means very little, and you should be
17able to upgrade to the latest release with little or no trouble (See notes in L<Catalyst::Upgrading>
18for specifics about your web server deployment).
19
20=head1 Writing your own PSGI file.
21
22=head2 What is a .psgi file
23
24A C<< .psgi >> file lets you manually controll how your application code reference is built.
25
26Catalyst normally takes care of this for you, but it's possible to do it manually by
27creating a C<myapp.psgi> file in the root of your application.
28
29The simplest C<.psgi> file for an application called C<TestApp> would be:
30
31 use strict;
32 use warnings;
33 use TestApp;
34
35 my $app = sub { TestApp->psgi_app(@_) };
36
37It should be noted that Catalyst may apply a number of middleware components for
38you automatically, and these B<will not> be applied if you manually create
24fd6115 39a psgi file yourself. Details of these middlewares can be found below.
ae908e7e 40
41Additional information about psgi files can be found at:
42L<http://search.cpan.org/dist/Plack/lib/Plack.pm#.psgi_files>
43
44=head2 Why would I want to make a .psgi file?
45
46Writing your own .psgi file allows you to use the alternate L<plackup> command
47to start your application, and allows you to add classes and extensions
48that implement L<Plack::Middleware>, such as L<Plack::Middleware::ErrorDocument>,
49or L<Plack::Middleware::AccessLog>.
50
51=head2 What is in the .psgi Catalyst generates by default?
52
a412b2f4 53Catalyst generates an application which, if the C<< using_frontend_proxy >>
54setting is on, is wrapped in L<Plack::Middleware::ReverseProxy>, and contains some
55engine specific fixes for uniform behaviour, as contained in:
56
57=over
58
0aafa77a 59=item L<Plack::Middleware::LighttpdScriptNameFix>
a412b2f4 60
61=item L<Plack::Middleware::IIS6ScriptNameFix>
62
63=item nginx - FIXME??
64
65=back
66
67If you override the default by providing your own C<< .psgi >> file, then
68none of these things will be done automatically for you by the PSGI
69application returned when you call C<< MyApp->psgi_app >>, and if you need
70any of this functionality, you'll need to implement this in your C<< .psgi >>
71file yourself.
72
d81c3c19 73An apply_default_middlewares method is supplied to wrap your application
74in the default middlewares if you want this behaviour and you are providing
75your own .psgi file.
3f22de0b 76
ae908e7e 77=head1 SEE ALSO
78
79L<Catalyst::Upgrading>, L<Plack>, L<PSGI::FAQ>, L<PSGI>.
80
81=head1 AUTHORS
82
83Catalyst Contributors, see Catalyst.pm
84
85=head1 COPYRIGHT
86
87This library is free software. You can redistribute it and/or modify
88it under the same terms as Perl itself.
89
90=cut