catalyst  

Re: [Catalyst] configurable base url?

Pablo Collins
Fri, 07 Dec 2007 09:44:51 -0800

Thanks guys for your help.

For clarity, I'd like to make the question webserver independent. For now, I'm just talking about how to change the base url of an application running in Catalyst::Engine::HTTP.

In Catalyst::Manual::Cookbook, the author states that $c->uri_for is great because it lets you "move an application around without having to worry that everything is going to break".

Maybe this is a dumb question, but how do you "move an application around" just in Catalyst::Engine::HTTP?

Regards,

-Pablo


Peter Edwards wrote:
Presuming that the only semantic meaning of 'versionn.nn' is splitting which
handler to go to, you can do this from Apache 2 with mod_rewrite. (If you
wanted to handle the version.nn dynamically within the app you'd need to
hanle the URL processing inside your app.)

In the Apache configuration, e.g. /etc/httpd/conf.d/myspecialapp.conf

<IfModule mod_rewrite.c>
<VirtualHost *:80>
   RewriteEngine     On
   RewriteLogLevel   0
   RewriteLog        /var/log/httpd/rewrite.log

   RewriteRule       ^/myspecialapp/version1.2/(.*$)
http://localhost:2502/$1  [P]
   ProxyPassReverse  /myspecialapp/version1.2/  http://localhost:2502/

   RewriteRule       ^/myspecialapp/version1.3/(.*$)
http://localhost:2503/$1  [P]
   ProxyPassReverse  /myspecialapp/version1.3/  http://localhost:2503/

   RewriteRule       ^proxy:.* - [F]
</VirtualHost>
</IfModule>

Then run your version 1.2 app listening at localhost port 2502 and your
version 1.3 app listening at localhost port 2503.
Apache will map incoming http://myserver/myspecialapp/version1.2/ on to
localhost:2502 and pass it path part /.
If Apache got back, say, path part /login it would return to the browser
http://myserver/myspecialapp/version1.2/login.

Regards, Peter
http://perl.dragonstaff.co.uk 

On 6. des.. 2007, at 18.32, Pablo Collins wrote:
  
Hi all,

I some catalyst apps whose different versions I'd like to make  
available by base path, like

http://mydomain/myspecialapp/version1.2/
http://mydomain/myspecialapp/version1.3/
etc.

I was planning on using a lighttpd or apache proxy to several  
Catalyst::Engine::HTTP processes running the different versions.  
That part is straightforward.

What I'm hung up on is how to tell catalyst to throw away the / 
myspecialapp/version1.3 part of the url and start the controller  
matching from there. I'd like to not have to change the names and  
namespaces of the controllers based on their versions if possible.

Instead I'd like to be able to put the application root url in the  
config and have it just work.

Is this possible / relatively easy to do?

Thanks much.

-Pablo

    



_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/

  

_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: [EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/