Debian Codegraph @

README

raw
1 NAME
2
3 Catalyst::Plugin::SmartURI - Configurable URIs for Catalyst
4
5 SYNOPSIS
6
7 In your lib/MyApp.pm, load the plugin and your other plugins, for
8 example:
9
10 use Catalyst qw/
11 -Debug
12 ConfigLoader
13 Static::Simple
14 Session
15 Session::Store::Memcached
16 Session::State::Cookie
17 Authentication
18 Authorization::Roles
19 +CatalystX::SimpleLogin
20 SmartURI
21 /;
22
23 In your .conf:
24
25 <Plugin::SmartURI>
26 disposition host-header # application-wide
27 uri_class URI::SmartURI # by default
28 </Plugin::SmartURI>
29
30 Per request:
31
32 $c->uri_disposition('absolute');
33
34 Methods on URIs:
35
36 <a href="[% c.uri_for('/foo').relative %]" ...
37
38 DESCRIPTION
39
40 Configure whether $c->uri_for and $c->req->uri_with return absolute,
41 hostless or relative URIs, or URIs based on the 'Host' header. Also
42 allows configuring which URI class to use. Works on application-wide or
43 per-request basis.
44
45 This is useful in situations where you're for example, redirecting to a
46 lighttpd from a firewall rule, instead of a real proxy, and you want
47 your links and redirects to still work correctly.
48
49 To use your own URI class, just subclass URI::SmartURI and set
50 uri_class, or write a class that follows the same interface.
51
52 This plugin installs a custom $c->request_class, however it does so in
53 a way that won't break if you've already set $c->request_class
54 yourself, ie. by using Catalyst::Action::REST (thanks mst!).
55
56 There is a minor performance penalty in perls older than 5.10, due to
57 Class::C3, but only at initialization time.
58
59 METHODS
60
61 $c->uri_for
62
63 $c->req->uri_with
64
65 Returns a $c->uri_class object (URI::SmartURI by default) in the
66 configured $c->uri_disposition.
67
68 $c->req->uri
69
70 Returns a $c->uri_class object. If the context hasn't been prepared
71 yet, uses the configured value for uri_class.
72
73 $c->req->uri->relative will be relative to $c->req->base.
74
75 $c->req->referer
76
77 Returns a $c->uri_class object for the referer (or configured uri_class
78 if there's no context) with reference set to $c->req->uri if it comes
79 from $c->req->base.
80
81 In other words, if referer is your app, you can do
82 $c->req->referer->relative and it will do the right thing.
83
84 CONFIGURATION
85
86 In myapp.conf:
87
88 <Plugin::SmartURI>
89 disposition absolute
90 uri_class URI::SmartURI
91 </Plugin::SmartURI>
92
93 disposition
94
95 One of 'absolute', 'hostless', 'relative' or 'host-header'. Defaults
96 to 'absolute'.
97
98 The special disposition 'host-header' uses the value of your 'Host:'
99 header.
100
101 uri_class
102
103 The class to use for URIs, defaults to URI::SmartURI.
104
105 PER REQUEST
106
107 package MyAPP::Controller::RSSFeed;
108
109 ...
110
111 sub begin : Private {
112 my ($self, $c) = @_;
113
114 $c->uri_class('Your::URI::Class::For::Request');
115 $c->uri_disposition('absolute');
116 }
117
118 $c->uri_disposition('absolute'|'hostless'|'relative'|'host-header')
119
120 Set URI disposition to use for the duration of the request.
121
122 $c->uri_class($class)
123
124 Set the URI class to use for $c->uri_for and $c->req->uri_with for
125 the duration of the request.
126
127 EXTENDING
128
129 $c->prepare_uri actually creates the URI, which you can override.
130
131 SEE ALSO
132
133 URI::SmartURI, Catalyst, URI
134
135 AUTHOR
136
137 Rafael Kitover, <rkitover at cpan.org>
138
139 BUGS
140
141 Please report any bugs or feature requests to
142 bug-catalyst-plugin-smarturi at rt.cpan.org, or through the web
143 interface at
144 http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Plugin-SmartURI.
145 I will be notified, and then you'll automatically be notified of
146 progress on your bug as I make changes.
147
148 SUPPORT
149
150 You can find documentation for this module with the perldoc command.
151
152 perldoc Catalyst::Plugin::SmartURI
153
154 You can also look for information at:
155
156 * RT: CPAN's request tracker
157
158 http://rt.cpan.org/NoAuth/Bugs.html?Dist=Catalyst-Plugin-SmartURI
159
160 * AnnoCPAN: Annotated CPAN documentation
161
162 http://annocpan.org/dist/Catalyst-Plugin-SmartURI
163
164 * CPAN Ratings
165
166 http://cpanratings.perl.org/d/Catalyst-Plugin-SmartURI
167
168 * Search CPAN
169
170 http://search.cpan.org/dist/Catalyst-Plugin-SmartURI
171
172 ACKNOWLEDGEMENTS
173
174 from #catalyst:
175
176 vipul came up with the idea
177
178 mst came up with the design and implementation details for the current
179 version
180
181 kd reviewed my code and offered suggestions
182
183 TODO
184
185 I'd like to extend on Catalyst::Plugin::RequireSSL, and make a plugin
186 that rewrites URIs for actions with an SSL attribute.
187
188 COPYRIGHT & LICENSE
189
190 Copyright (c) 2008 Rafael Kitover
191
192 This program is free software; you can redistribute it and/or modify it
193 under the same terms as Perl itself.
194