[Catalyst] Changing a base url in mod_perl
Matt S Trout
dbix-class at trout.me.uk
Fri Dec 30 23:07:03 CET 2005
On Fri, Dec 30, 2005 at 01:32:49PM -0800, Ovid wrote:
> Hi all,
>
> In my search controller, I have the following method defined:
>
> sub search : Regex( '^search/([[:alpha:]][[:word:]]*)(?:/(squery|slookup)(?:/(.*))?)?$') {
> ....
> }
>
> That allows users to use URLs like the following:
>
> http://www.example.com/search/simple/squery/some/search/params
>
> However, I need users to be able to dispatch to different base URLs:
>
> http://www.example.com/catalyst/search/simple/squery/some/search/params
>
> I need the user at build time to be able to specify their own base url so I can do something like this:
Why do you need to specify this at build time? Under (e.g.) mod_perl Catalyst
will auto-detect it's base URL and Just Handle It, and in the general case
it's trivial to set the base URL from a config.yml
> sub search : Regex("^$base_url/search/([[:alpha:]][[:word:]]*)(?:/(squery|slookup)(?:/(.*))?)?$") {
> ....
> }
>
> I realize that syntax won't work, but I'm not sure how this is actually handled.
If you need to do more than one of these within the app, you could create
MyApp::Controller::Search1 etc.
with have a sub action_namespace { 'catalyst' } or whatever injected plus
inherit from your base search controller, and use :LocalRegex('^/search/...
to have the base namespace automatically prepended to the regex during
dispatcher setup.
--
Matt S Trout Offering custom development, consultancy and support
Technical Director contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information
+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +
More information about the Catalyst
mailing list