Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages
Catalyst::Plugin::SmartURI(3) User Contributed Perl Documentation Catalyst::Plugin::SmartURI(3)

Catalyst::Plugin::SmartURI - Configurable URIs for Catalyst

In your lib/, load the plugin and your other plugins, for example:

    use Catalyst qw/

In your .conf:

        disposition host-header   # application-wide
        uri_class   URI::SmartURI # by default

Per request:


Methods on URIs:

    <a href="[% c.uri_for('/foo').relative %]" ...

Configure whether "$c->uri_for" and "$c->req->uri_with" return absolute, hostless or relative URIs, or URIs based on the 'Host' header. Also allows configuring which URI class to use. Works on application-wide or per-request basis.

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.

To use your own URI class, just subclass URI::SmartURI and set "uri_class", or write a class that follows the same interface.

This plugin installs a custom "$c->request_class", however it does so in a way that won't break if you've already set "$c->request_class" yourself, ie. by using Catalyst::Action::REST (thanks mst!).

There is a minor performance penalty in perls older than 5.10, due to Class::C3, but only at initialization time.

Returns a "$c->uri_class" object (URI::SmartURI by default) in the configured "$c->uri_disposition".

Returns a "$c->uri_class" object. If the context hasn't been prepared yet, uses the configured value for "uri_class".

"$c->req->uri->relative" will be relative to "$c->req->base".

Returns a "$c->uri_class" object for the referer (or configured "uri_class" if there's no context) with reference set to "$c->req->uri" if it comes from "$c->req->base".

In other words, if referer is your app, you can do "$c->req->referer->relative" and it will do the right thing.

In myapp.conf:

        disposition absolute
        uri_class   URI::SmartURI
One of 'absolute', 'hostless', 'relative' or 'host-header'. Defaults to 'absolute'.

The special disposition 'host-header' uses the value of your 'Host:' header.

The class to use for URIs, defaults to URI::SmartURI.

    package MyAPP::Controller::RSSFeed;


    sub begin : Private {
        my ($self, $c) = @_;

Set URI disposition to use for the duration of the request.
Set the URI class to use for "$c->uri_for" and "$c->req->uri_with" for the duration of the request.

"$c->prepare_uri" actually creates the URI, which you can override.

URI::SmartURI, Catalyst, URI

Rafael Kitover, "<rkitover at>"

Please report any bugs or feature requests to "bug-catalyst-plugin-smarturi at", 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.

You can find documentation for this module with the perldoc command.

    perldoc Catalyst::Plugin::SmartURI

You can also look for information at:

  • RT: CPAN's request tracker


  • AnnoCPAN: Annotated CPAN documentation


  • CPAN Ratings


  • Search CPAN


from #catalyst:

vipul came up with the idea

mst came up with the design and implementation details for the current version

kd reviewed my code and offered suggestions

I'd like to extend on Catalyst::Plugin::RequireSSL, and make a plugin that rewrites URIs for actions with an SSL attribute.

Copyright (c) 2008 Rafael Kitover

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2015-10-04 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.