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