add %_ setting
[catagits/Web-Simple.git] / lib / Web / Simple / Deployment.pod
CommitLineData
4f83bde7 1=head1 NAME
2
3Web::Simple::Deployment - various deployment options
4
5=head1 DESCRIPTION
6
7This file documents common deployment methods for Web::Simple. If you feel one
8is missing, please ask in the IRC channel and we'll work with you to add it.
9
10=head1 CGI
11
12The most basic deployment option is as a CGI script loading and running your
13Web::Simple-module:
14
15 #!/usr/bin/env perl
16
17 use Your::Web::Simple::App;
18 Your::Web::Simple::App->run_if_script;
19
20Save that as script.cgi and your web server will handle it correctly.
21
dfcd788c 22=head1 Plack-Server
23
24This works in with exactly the same code as CGI deployment. However instead of
25letting your web server load script.cgi, you run this on the command line:
26
27 plackup script.cgi
28
4f83bde7 29=head2 Self-contained CGI
30
31Sometimes your app is so small that you have only one or two tiny classes that
32you want to run as a CGI script. Web::Simple offers a helpful mechanism to
33achieve that.
34
35 #!/usr/bin/env perl
36
37 use Web::Simple 'HelloWorld'; # enables strictures and warnings for the file
38 # additionally, HelloWorld is upgraded to a
39 # Web::Simple application
40 {
41 package HelloWorld;
42
43 sub dispatch_request {
44 sub (GET) {
45 [
46 200,
47 [ 'Content-type', 'text/plain' ],
48 [ 'Hello world! It is a fine ' . HelloWorld::Helper->day ]
49 ]
50 },
51 sub () {
52 [ 405, [ 'Content-type', 'text/plain' ], [ 'Method not allowed' ] ]
53 }
54 }
55 }
56
57 {
58 package HelloWorld::Helper;
59
60 use DateTime;
61
62 sub day {
63 return DateTime->now->day_name;
64 }
65 }
66
67 HelloWorld->run_if_script;
68
69=head1 AUTHORS
70
71See L<Web::Simple> for authors.
72
73=head1 COPYRIGHT AND LICENSE
74
75See L<Web::Simple> for the copyright and license.
76
77=cut