luckyframework / lucky

A full-featured Crystal web framework that catches bugs for you, runs incredibly fast, and helps you write code that lasts.
https://luckyframework.org
MIT License
2.57k stars 156 forks source link

Add subdomain support to RouteHelper #1753

Open jwoertink opened 1 year ago

jwoertink commented 1 year ago

If you have part of your application that need to be under a subdomain, there's currently no way to use link() to go to the action with that subdomain.

We could do this:

link to: Admin::Dashboard.with(subdomain: "admin")

https://github.com/luckyframework/lucky/blob/main/src/lucky/route_helper.cr

https://github.com/luckyframework/lucky/blob/8d0681a086ff0985e58a319f9ded9002a17eb4e8/src/lucky/routable.cr#L317

Or alternatively, we could make actions with subdomains auto redirect?

# something like this?
require_subdomain "admin", auto_redirect: true

# this would show "/dashboard", but then auto redirect to admin.whatever.site/dashboard
link to: Admin::Dashboard

Though.... thinking about it, that second idea might not be good because then EVERY link would always 302 :thinking:

I'm mainly looking for a way where I can say some links go to subdomain pages, and some don't.