Hi all, I have a need for the use of subdomains being mapped to accounts and could not find a plugin or middleware already written, so I have whipped up a Dancer::Middleware::Subdomain library and have it up on github. https://github.com/mvickers/dancer_middleware_subdomain Comments/Criticisms are welcome. Matt
Wow! I think this will prove itself very useful, and we already have a ticket of a person who needs exactly this behavior (GH #248). Do you think that ticket can be handled by Dancer::Middleware::Subdomain? On Sun, Feb 13, 2011 at 6:29 AM, Matthew Vickers <mvickers@quispiam.com>wrote:
Hi all,
I have a need for the use of subdomains being mapped to accounts and could not find a plugin or middleware already written, so I have whipped up a Dancer::Middleware::Subdomain library and have it up on github.
https://github.com/mvickers/dancer_middleware_subdomain
Comments/Criticisms are welcome.
Matt _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
Hey sawyer, Thanks for the wow ! I am not very plack literate but I do not think this middleware would suit ticket 284. It seems that harshalls wants to mount different apps at different subdomains. All Dancer::Middleware::Subdomain does is set $env->{ SUBDOMAIN } to the subdomain, I use it so that I can map an account to a sub domain ala freshbooks. Can logic be placed in the builder block ? builder { if($env->{ SUBDOMAIN } eq 'foo') { mount ... } if($env->{ SUBDOMAIN } eq 'bar') { mount ... } } Perhaps someone with more perl/Dancer foo than I can hack it to fix the issue. Matt On 13/02/11 8:54 PM, sawyer x wrote:
Wow!
I think this will prove itself very useful, and we already have a ticket of a person who needs exactly this behavior (GH #248).
Do you think that ticket can be handled by Dancer::Middleware::Subdomain?
On Sun, Feb 13, 2011 at 6:29 AM, Matthew Vickers <mvickers@quispiam.com <mailto:mvickers@quispiam.com>> wrote:
Hi all,
I have a need for the use of subdomains being mapped to accounts and could not find a plugin or middleware already written, so I have whipped up a Dancer::Middleware::Subdomain library and have it up on github.
https://github.com/mvickers/dancer_middleware_subdomain
Comments/Criticisms are welcome.
Matt _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org <mailto:Dancer-users@perldancer.org> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
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 On Sun, Feb 13, 2011 at 4:01 PM, Matthew Vickers <mvickers@quispiam.com>wrote:
Hey sawyer,
Thanks for the wow !
I am not very plack literate but I do not think this middleware would suit ticket 284. It seems that harshalls wants to mount different apps at different subdomains. All Dancer::Middleware::Subdomain does is set $env->{ SUBDOMAIN } to the subdomain, I use it so that I can map an account to a sub domain ala freshbooks.
Can logic be placed in the builder block ?
builder { if($env->{ SUBDOMAIN } eq 'foo') { mount ... } if($env->{ SUBDOMAIN } eq 'bar') { mount ... } }
Perhaps someone with more perl/Dancer foo than I can hack it to fix the issue.
Matt
On 13/02/11 8:54 PM, sawyer x wrote:
Wow!
I think this will prove itself very useful, and we already have a ticket of a person who needs exactly this behavior (GH #248).
Do you think that ticket can be handled by Dancer::Middleware::Subdomain?
On Sun, Feb 13, 2011 at 6:29 AM, Matthew Vickers <mvickers@quispiam.com>wrote:
Hi all,
I have a need for the use of subdomains being mapped to accounts and could not find a plugin or middleware already written, so I have whipped up a Dancer::Middleware::Subdomain library and have it up on github.
https://github.com/mvickers/dancer_middleware_subdomain
Comments/Criticisms are welcome.
Matt _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
_______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
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
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@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@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
On 14/02/11 6:52 AM, Matthew Vickers wrote:
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 }
Just tried the above and unfortunately it does not work, seems request is undefined. Maybe that someone else on the list can get this library to do what you need. Matt.
participants (3)
-
Harshal Shah -
Matthew Vickers -
sawyer x