roman has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,

I am looking for a solution of - what I think is quite typical issue - but I was not successfull so far.

I am building a Catalyst application (say MyCatApp), with couple of web interfaces for different kind of users.

The interfaces should be accessible via subdomains:

All interfaces will be powered by a single Apache server.

What approach to choose?

Separate applications

Three different applications (MyCatApp::Public, MyCatApp::Provider, MyCatApp::Admin) sharing model (and probably some templates) with unique set of controllers (MyCatApp::Public::Controller::Deal, ... ).

This approach involves more code and inheritance and disallow (internal) calls between controllers from different interfaces.

On the other hand I can imagine the deployment where each application serves as handler for one virtual host in Apache config.

One application

One application with each interface having its controller namespace (MyCatApp::Controller::Public::Deal, MyCatApp::Controller::Provider::Order, ...). I think less modules, less namespaces involved, probably more comfortable coding.

But I am not sure about deployment, also about Catalyst URI to internal paths and vice versa resolution. Should I have again three virtual hosts but handled by the same application? How should I achieve that:

http://provider.mycatapp.xyz/order is resolved to /provider/order http://provider.mycatapp.xyz/deal is rejected # and vice versa $c->uri_for('/provider/order') # yields http://provider.mycatapp.xyz/order

What approach would you choose? Thank you very much for any recommendation.

Replies are listed 'Best First'.
Re: How to build multirealm Catalyst application
by stonecolddevin (Parson) on Jul 25, 2010 at 20:59 UTC

    A single app would be fine. Just mod_rewrite the urls (since you're using apache) to the appropriate app urls. and use $c->uri_for_action over the nasty string passing to uri_for. Things just get messy if you do that. Plus, it gives you the benefit of only needing to know the private path, with Catalyst taking care of generating the URL properly, in case you decide to move things around or change names/API.

    mtfnpy

      Thanks for your reply. One app seems more and more maintainable for me. But there is one thing I can't get

      I can imagine that mod_rewrite turns http://provider.mycatapp.xyz/order/123 into http://mycatapp.xyz/provider/order/123

      But which piece of code converts the http://mycatapp.xyz/provider/payments (result of $c->uri_for_action('/provider/payments')) back into http://provider.mycatapp.xyz/payments?

        I don't have hardly any mod_perl experience, however, I'm fairly certain they way you would do this in nginx is to mess with the say, fastcgi params (if you were in fact deploying to fastcgi). Basically Catalyst just needs to know the base url a given domain consists of. I will look around to see if I can find anything more coherent regarding this.

        mtfnpy

Re: How to build multirealm Catalyst application
by metaperl (Curate) on Jul 27, 2010 at 14:18 UTC