* Duane Johnson ([EMAIL PROTECTED]) [051207 14:00]: > I have a patch coming soon (when I get authorization from my > employer) that will allow the use of the host name (domain, subdomain > etc.) in routes. Here's the syntax I'm working with right now: > > map.connect '//:host/:controller/:action/:id' > map.connect '//:host/:action/:id', :host => /two\..+/, :controller > => 'two' > map.connect '//:host/:id', :host => /one\..+/, :controller => > 'one', :action => 'list' > > The last route, for example, would route to OneController#list when > the URL "http://one.localhost:3000/123" or "http://one.mydomain.com/ > 123" is given. > > I needed some way to distinguish between routes that care about the > host and routes that don't. Thus, I've prepended a "//" in front to > denote "I care about the host and my first symbol should be match > against the host". In the example URLs above, the :host Regexp will > be compared with "one.localhost" and "one.mydomain.com". > > I think it would be natural for most developers to prepend a '//' > since it closely follows the URI format of protocol://domain/path? > query_string. > > Thoughts?
I like the idea on some level, though I wonder: How well does it play (API-wise) with the logical extensions of asking for port, protocol, username & password (HTTP Basic)? Port is problematic due to the normal /:\d+/ pattern used. The web server often handles functional redirection based upon host. The request object will have the various URL components and a filter could be used to alter functionality based upon those URL components. All I'm saying there is that there are usually other ways to make behavior conditional. I do like the idea of being able to put that sort of control straight into the routes, but my only objection at the moment is syntactical -- not in the current suggestion but the next obvious improvement to the current suggestion. Rick -- http://www.rickbradley.com MUPRN: 785 | much ascribes to random email haiku | the unix philosophy | one tool for one job. _______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core