minor doc changes
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Request.pm
1 package Catalyst::Request;
2
3 use strict;
4 use base 'Class::Accessor::Fast';
5
6 __PACKAGE__->mk_accessors(
7     qw/action address arguments base cookies headers hostname match method
8       parameters path snippets uploads/
9 );
10
11 *args   = \&arguments;
12 *params = \&parameters;
13
14 =head1 NAME
15
16 Catalyst::Request - Catalyst Request Class
17
18 =head1 SYNOPSIS
19
20
21     $req = $c->request;
22     $req->action;
23     $req->address;
24     $req->args;
25     $req->arguments;
26     $req->base;
27     $req->cookies;
28     $req->headers;
29     $req->hostname;
30     $req->match;
31     $req->method;
32     $req->parameters;
33     $req->params;
34     $req->path;
35     $req->snippets;
36     $req->uploads;
37
38 See also L<Catalyst>.
39
40 =head1 DESCRIPTION
41
42 This is the Catalyst Request class, which provides a set of accessors to the
43 request data.  The request object is prepared by the specialized Catalyst
44 Engine module thus hiding the details of the particular engine implementation.
45
46
47 =head1 METHODS
48
49 =over 4
50
51 =item $req->action
52
53 Contains the action.
54
55     print $c->request->action;
56
57 =item $req->address
58
59 Contains the remote address.
60
61     print $c->request->address
62
63 =item $req->arguments
64
65 =item $req->args
66
67 Returns a reference to an array containing the arguments.
68
69     print $c->request->arguments->[0];
70
71 =item $req->base
72
73 Contains the uri base.
74
75 =item $req->cookies
76
77 Returns a reference to a hash containing the cookies.
78
79     print $c->request->cookies->{mycookie}->value;
80
81 =item $req->headers
82
83 Returns an L<HTTP::Headers> object containing the headers.
84
85     print $c->request->headers->header('X-Catalyst');
86
87 =item $req->hostname
88
89 Contains the remote hostname.
90
91     print $c->request->hostname
92
93 =item $req->match
94
95 Contains the match.
96
97     print $c->request->match;
98
99 =item $req->parameters
100
101 =item $req->params
102
103 Returns a reference to a hash containing the parameters.
104
105     print $c->request->parameters->{foo};
106
107 =item $req->path
108
109 Contains the path.
110
111     print $c->request->path;
112
113 =item $req->method
114
115 Contains the request method (C<GET>, C<POST>, C<HEAD>, etc).
116
117     print $c->request->method
118
119 =item $req->snippets
120
121 Returns a reference to an array containing regex snippets.
122
123     my @snippets = @{ $c->request->snippets };
124
125 =item $req->uploads
126
127 Returns a reference to a hash containing the uploads.
128
129     my $filename = $c->req->parameters->{foo};
130     print $c->request->uploads->{$filename}->{type};
131     print $c->request->uploads->{$filename}->{size};
132     my $fh = $c->request->uploads->{$filename}->{fh};
133     my $content = do { local $/; <$fh> };
134
135 =back
136
137 =head1 AUTHOR
138
139 Sebastian Riedel, C<sri@cpan.org>
140
141 =head1 COPYRIGHT
142
143 This program is free software, you can redistribute it and/or modify it under
144 the same terms as Perl itself.
145
146 =cut
147
148 1;