.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Catalyst::Plugin::SmartURI 3pm" .TH Catalyst::Plugin::SmartURI 3pm "2022-06-09" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Catalyst::Plugin::SmartURI \- Configurable URIs for Catalyst .SH "SYNOPSIS" .IX Header "SYNOPSIS" In your lib/MyApp.pm, load the plugin and your other plugins, for example: .PP .Vb 12 \& use Catalyst qw/ \& \-Debug \& ConfigLoader \& Static::Simple \& Session \& Session::Store::Memcached \& Session::State::Cookie \& Authentication \& Authorization::Roles \& +CatalystX::SimpleLogin \& SmartURI \& /; .Ve .PP In your .conf: .PP .Vb 4 \& \& disposition host\-header # application\-wide \& uri_class URI::SmartURI # by default \& .Ve .PP Per request: .PP .Vb 1 \& $c\->uri_disposition(\*(Aqabsolute\*(Aq); .Ve .PP Methods on URIs: .PP .Vb 1 \& uri_for\*(C'\fR and \f(CW\*(C`$c\->req\->uri_with\*(C'\fR return absolute, hostless or relative URIs, or URIs based on the 'Host' header. Also allows configuring which \&\s-1URI\s0 class to use. Works on application-wide or per-request basis. .PP This is useful in situations where you're for example, redirecting to a lighttpd from a firewall rule, instead of a real proxy, and you want your links and redirects to still work correctly. .PP To use your own \s-1URI\s0 class, just subclass URI::SmartURI and set \&\f(CW\*(C`uri_class\*(C'\fR, or write a class that follows the same interface. .PP This plugin installs a custom \f(CW\*(C`$c\->request_class\*(C'\fR, however it does so in a way that won't break if you've already set \f(CW\*(C`$c\->request_class\*(C'\fR yourself, ie. by using Catalyst::Action::REST (thanks mst!). .PP There is a minor performance penalty in perls older than 5.10, due to Class::C3, but only at initialization time. .SH "METHODS" .IX Header "METHODS" .ie n .SS "$c\->uri_for" .el .SS "\f(CW$c\fP\->uri_for" .IX Subsection "$c->uri_for" .ie n .SS "$c\->req\->uri_with" .el .SS "\f(CW$c\fP\->req\->uri_with" .IX Subsection "$c->req->uri_with" Returns a \f(CW\*(C`$c\->uri_class\*(C'\fR object (URI::SmartURI by default) in the configured \&\f(CW\*(C`$c\->uri_disposition\*(C'\fR. .ie n .SS "$c\->req\->uri" .el .SS "\f(CW$c\fP\->req\->uri" .IX Subsection "$c->req->uri" Returns a \f(CW\*(C`$c\->uri_class\*(C'\fR object. If the context hasn't been prepared yet, uses the configured value for \f(CW\*(C`uri_class\*(C'\fR. .PP \&\f(CW\*(C`$c\->req\->uri\->relative\*(C'\fR will be relative to \f(CW\*(C`$c\->req\->base\*(C'\fR. .ie n .SS "$c\->req\->referer" .el .SS "\f(CW$c\fP\->req\->referer" .IX Subsection "$c->req->referer" Returns a \f(CW\*(C`$c\->uri_class\*(C'\fR object for the referer (or configured \f(CW\*(C`uri_class\*(C'\fR if there's no context) with reference set to \f(CW\*(C`$c\->req\->uri\*(C'\fR if it comes from \&\f(CW\*(C`$c\->req\->base\*(C'\fR. .PP In other words, if referer is your app, you can do \&\f(CW\*(C`$c\->req\->referer\->relative\*(C'\fR and it will do the right thing. .SH "CONFIGURATION" .IX Header "CONFIGURATION" In myapp.conf: .PP .Vb 4 \& \& disposition absolute \& uri_class URI::SmartURI \& .Ve .IP "disposition" 4 .IX Item "disposition" One of 'absolute', 'hostless', 'relative' or 'host\-header'. Defaults to \&'absolute'. .Sp The special disposition 'host\-header' uses the value of your 'Host:' header. .IP "uri_class" 4 .IX Item "uri_class" The class to use for URIs, defaults to URI::SmartURI. .SH "PER REQUEST" .IX Header "PER REQUEST" .Vb 1 \& package MyAPP::Controller::RSSFeed; \& \& ... \& \& sub begin : Private { \& my ($self, $c) = @_; \& \& $c\->uri_class(\*(AqYour::URI::Class::For::Request\*(Aq); \& $c\->uri_disposition(\*(Aqabsolute\*(Aq); \& } .Ve .ie n .IP "$c\->uri_disposition('absolute'|'hostless'|'relative'|'host\-header')" 4 .el .IP "\f(CW$c\fR\->uri_disposition('absolute'|'hostless'|'relative'|'host\-header')" 4 .IX Item "$c->uri_disposition('absolute'|'hostless'|'relative'|'host-header')" Set \s-1URI\s0 disposition to use for the duration of the request. .ie n .IP "$c\->uri_class($class)" 4 .el .IP "\f(CW$c\fR\->uri_class($class)" 4 .IX Item "$c->uri_class($class)" Set the \s-1URI\s0 class to use for \f(CW\*(C`$c\->uri_for\*(C'\fR and \f(CW\*(C`$c\->req\->uri_with\*(C'\fR for the duration of the request. .SH "EXTENDING" .IX Header "EXTENDING" \&\f(CW\*(C`$c\->prepare_uri\*(C'\fR actually creates the \s-1URI,\s0 which you can override. .SH "SEE ALSO" .IX Header "SEE ALSO" URI::SmartURI, Catalyst, \s-1URI\s0 .SH "AUTHOR" .IX Header "AUTHOR" Rafael Kitover, \f(CW\*(C`\*(C'\fR .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests to \&\f(CW\*(C`bug\-catalyst\-plugin\-smarturi at rt.cpan.org\*(C'\fR, or through the web interface at . I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. .SH "SUPPORT" .IX Header "SUPPORT" You can find documentation for this module with the perldoc command. .PP .Vb 1 \& perldoc Catalyst::Plugin::SmartURI .Ve .PP You can also look for information at: .IP "\(bu" 4 \&\s-1RT: CPAN\s0's request tracker .Sp .IP "\(bu" 4 AnnoCPAN: Annotated \s-1CPAN\s0 documentation .Sp .IP "\(bu" 4 \&\s-1CPAN\s0 Ratings .Sp .IP "\(bu" 4 Search \s-1CPAN\s0 .Sp .SH "ACKNOWLEDGEMENTS" .IX Header "ACKNOWLEDGEMENTS" from #catalyst: .PP vipul came up with the idea .PP mst came up with the design and implementation details for the current version .PP kd reviewed my code and offered suggestions .SH "TODO" .IX Header "TODO" I'd like to extend on Catalyst::Plugin::RequireSSL, and make a plugin that rewrites URIs for actions with an \s-1SSL\s0 attribute. .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright (c) 2008 Rafael Kitover .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.