[Dancer-users] Plack Middleware for subdomains

Harshal Shah harshal.shah at gmail.com
Mon Feb 14 07:07:51 CET 2011


Hi Matt,

will it be able to register same routes under different subdomains ?

if(request->env->{ 'domain1' }){

    get '/' => sub { return 'from Domain 1 ' };
 }

 package Domain2App

  if(request->env->{ 'domain2'}) {
      get '/' => sub { return 'from Domain 2 ' };
 }

package MasterApp

load_app 'Domain1App', 'Domain2App';

dance;

Harshal Shah


On Mon, Feb 14, 2011 at 1:22 AM, Matthew Vickers <mvickers at quispiam.com>wrote:

> On 13/02/11 10:54 PM, Harshal Shah wrote:
>
>> Hey Matt
>>
>> Thanks for the work... As for ticket 284, I was trying to host multiple
>> tiny dancer apps, sharing a core functionality. Can we take this module
>> further and do something like
>>
>> package Domain1App
>>
>> prefix_domain 'domain1' ;
>>
>> ## domain 1 specific routes
>>
>> package Domain2App
>>
>> prefix_domain 'domain2' ;
>>
>> ## domain 2 specific routes
>>
>> still running as single dancer app ? Though i cant think of a way to
>> handle different config files for each of them ?
>>
>>
>>
>> Harshal Shah
>>
>>  Hi Harshal,
>
> I am not sure, do you think the following would work ?
>
>  package Domain1App
>
>  if(request->env->{ 'domain1' }){
>
>      ## domain 1 specific routes
>  }
>
>  package Domain2App
>
>   if(request->env->{ 'domain2'}) {
>      ## domain 2 specific routes
>  }
>
> If that works can a  helper function like the following be written ?
>  Something similar to the prefix function ?
> It would probably have to be a plugin as this sort of functionality is
> probably not desired in core
>
>    sub subdomain {
>        my $subdomain = shift;
>        ...
>
>    }
>
> Matt
>
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20110214/8bb12c9e/attachment.htm>


More information about the Dancer-users mailing list