[Catalyst] Overriding uri_for() -- sane? better way

apv apv at sedition.com
Sun Jan 15 01:57:39 CET 2006


Using an .htaccess rewrite like so (partially cargo culted):

  DirectoryIndex index.fcgi index.pl

  RewriteCond %{REQUEST_FILENAME}   !-d
  RewriteCond %{REQUEST_FILENAME}   !-f
  RewriteRule ^(.*) index.fcgi/$1 [QSA,L]

I can get nice relative URIs from wherever the app is. But they get the
   /wherever/index.fcgi/path/args
with the index file inserted in there. Nothing wrong with it but it's
not necessary, terse, or pretty. So I'm overriding uri_for() like so:

  *Catalyst::uri_for =
  sub {
  # nothing changes until last line, then we
  # tweak the $res before returning it
      $res =~ s{/index.(?:fcgi|pl)}{};
      $res;
  };

I think there is probably a better way to do this, yes?

-Ashley




More information about the Catalyst mailing list