1Plack(3) User Contributed Perl Documentation Plack(3)
2
3
4
6 Plack - Perl Superglue for Web frameworks and Web Servers (PSGI
7 toolkit)
8
10 Plack is a set of tools for using the PSGI stack. It contains
11 middleware components, a reference server and utilities for Web
12 application frameworks. Plack is like Ruby's Rack or Python's Paste for
13 WSGI.
14
15 See PSGI for the PSGI specification and PSGI::FAQ to know what PSGI and
16 Plack are and why we need them.
17
19 Plack::Handler
20 Plack::Handler and its subclasses contains adapters for web servers. We
21 have adapters for the built-in standalone web server
22 HTTP::Server::PSGI, CGI, FCGI, Apache1, Apache2 and
23 HTTP::Server::Simple included in the core Plack distribution.
24
25 There are also many HTTP server implementations on CPAN that have Plack
26 handlers.
27
28 See Plack::Handler when writing your own adapters.
29
30 Plack::Loader
31 Plack::Loader is a loader to load one Plack::Handler adapter and run a
32 PSGI application code reference with it.
33
34 Plack::Util
35 Plack::Util contains a lot of utility functions for server implementors
36 as well as middleware authors.
37
38 .psgi files
39 A PSGI application is a code reference but it's not easy to pass code
40 reference via the command line or configuration files, so Plack uses a
41 convention that you need a file named "app.psgi" or similar, which
42 would be loaded (via perl's core function "do") to return the PSGI
43 application code reference.
44
45 # Hello.psgi
46 my $app = sub {
47 my $env = shift;
48 # ...
49 return [ $status, $headers, $body ];
50 };
51
52 If you use a web framework, chances are that they provide a helper
53 utility to automatically generate these ".psgi" files for you, such as:
54
55 # MyApp.psgi
56 use MyApp;
57 my $app = sub { MyApp->run_psgi(@_) };
58
59 It's important that the return value of ".psgi" file is the code
60 reference. See "eg/dot-psgi" directory for more examples of ".psgi"
61 files.
62
63 plackup, Plack::Runner
64 plackup is a command line launcher to run PSGI applications from
65 command line using Plack::Loader to load PSGI backends. It can be used
66 to run standalone servers and FastCGI daemon processes. Other server
67 backends like Apache2 needs a separate configuration but ".psgi"
68 application file can still be the same.
69
70 If you want to write your own frontend that replaces, or adds
71 functionalities to plackup, take a look at the Plack::Runner module.
72
73 Plack::Middleware
74 PSGI middleware is a PSGI application that wraps an existing PSGI
75 application and plays both side of application and servers. From the
76 servers the wrapped code reference still looks like and behaves exactly
77 the same as PSGI applications.
78
79 Plack::Middleware gives you an easy way to wrap PSGI applications with
80 a clean API, and compatibility with Plack::Builder DSL.
81
82 Plack::Builder
83 Plack::Builder gives you a DSL that you can enable Middleware in
84 ".psgi" files to wrap existent PSGI applications.
85
86 Plack::Request, Plack::Response
87 Plack::Request gives you a nice wrapper API around PSGI $env hash to
88 get headers, cookies and query parameters much like Apache::Request in
89 mod_perl.
90
91 Plack::Response does the same to construct the response array
92 reference.
93
94 Plack::Test
95 Plack::Test is a unified interface to test your PSGI application using
96 standard HTTP::Request and HTTP::Response pair with simple callbacks.
97
98 Plack::Test::Suite
99 Plack::Test::Suite is a test suite to test a new PSGI server backend.
100
102 Patches and Bug Fixes
103 Small patches and bug fixes can be either submitted via nopaste on IRC
104 <irc://irc.perl.org/#plack> or the github issue tracker
105 <http://github.com/plack/Plack/issues>. Forking on github
106 <http://github.com/plack/Plack> is another good way if you intend to
107 make larger fixes.
108
109 See also <http://contributing.appspot.com/plack> when you think this
110 document is terribly outdated.
111
112 Module Namespaces
113 Modules added to the Plack:: sub-namespaces should be reasonably
114 generic components which are useful as building blocks and not just
115 simply using Plack.
116
117 Middleware authors are free to use the Plack::Middleware:: namespace
118 for their middleware components. Middleware must be written in the
119 pipeline style such that they can chained together with other
120 middleware components. The Plack::Middleware:: modules in the core
121 distribution are good examples of such modules. It is recommended that
122 you inherit from Plack::Middleware for these types of modules.
123
124 Not all middleware components are wrappers, but instead are more like
125 endpoints in a middleware chain. These types of components should use
126 the Plack::App:: namespace. Again, look in the core modules to see
127 excellent examples of these (Plack::App::File, Plack::App::Directory,
128 etc.). It is recommended that you inherit from Plack::Component for
129 these types of modules.
130
131 DO NOT USE Plack:: namespace to build a new web application or a
132 framework. It's like naming your application under CGI:: namespace if
133 it's supposed to run on CGI and that is a really bad choice and would
134 confuse people badly.
135
137 Tatsuhiko Miyagawa
138
140 The following copyright notice applies to all the files provided in
141 this distribution, including binary files, unless explicitly noted
142 otherwise.
143
144 Copyright 2009-2013 Tatsuhiko Miyagawa
145
147 Tatsuhiko Miyagawa (miyagawa)
148
149 Tokuhiro Matsuno (tokuhirom)
150
151 Jesse Luehrs (doy)
152
153 Tomas Doran (bobtfish)
154
155 Graham Knop (haarg)
156
158 Yuval Kogman (nothingmuch)
159
160 Kazuhiro Osawa (Yappo)
161
162 Kazuho Oku
163
164 Florian Ragwitz (rafl)
165
166 Chia-liang Kao (clkao)
167
168 Masahiro Honma (hiratara)
169
170 Daisuke Murase (typester)
171
172 John Beppu
173
174 Matt S Trout (mst)
175
176 Shawn M Moore (Sartak)
177
178 Stevan Little
179
180 Hans Dieter Pearcey (confound)
181
182 mala
183
184 Mark Stosberg
185
186 Aaron Trevena
187
189 The PSGI specification upon which Plack is based.
190
191 <http://plackperl.org/>
192
193 The Plack wiki: <https://github.com/plack/Plack/wiki>
194
195 The Plack FAQ: <https://github.com/plack/Plack/wiki/Faq>
196
198 This library is free software; you can redistribute it and/or modify it
199 under the same terms as Perl itself.
200
201
202
203perl v5.38.0 2023-07-21 Plack(3)