rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
* dynamic map url to class using rack?
@ 2009-06-05 14:02 gsw
  0 siblings, 0 replies; only message in thread
From: gsw @ 2009-06-05 14:02 UTC (permalink / raw)
  To: Rack Development


Hey,

I have a serious newb question, so hopefully it isn't too nuts. I'd
like to be able to do something like this dynamically:

map "/(service)/(version)/*" do
  run (module corresponding to service)::(module corresponding to
version)::Controller
end

I don't think this is currently possible, but maybe I'm wrong. Might
it be possible in the future with rack, or would that be a bad idea?

I know that currently I could do it non-dynamically like:

map "/actual_service_name" do
  map "/actual_version_name" do
    run ActualServiceName::ActualVersionName::Controller
  end

  map "/another_actual_version_name" do
    run ActualServiceName::AnotherActualVersionName::Controller
  end
end

map "/another_actual_service_name" do
  map "/actual_version_name" do
    run AnotherActualServiceName::ActualVersionName::Controller
  end

  map "/another_actual_version_name" do
    run AnotherActualServiceName::AnotherActualVersionName::Controller
  end
end

The goal is have Sinatra controller classes that extend Sinatra::Base
in directories like:

/lib/service_name/version_name/controller.rb
/lib/service_name/another_version_name/controller.rb
/lib/another_service_name/version_name/controller.rb
/lib/another_service_name/another_version_name/controller.rb

Thanks in advance!
Gary

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-06-05 14:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-05 14:02 dynamic map url to class using rack? gsw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).