From: gsw <garysweaver@gmail.com>
To: Rack Development <rack-devel@googlegroups.com>
Subject: dynamic map url to class using rack?
Date: Fri, 5 Jun 2009 07:02:09 -0700 (PDT) [thread overview]
Message-ID: <af13daec-08e9-4e08-86cc-3e770ab6740a@s21g2000vbb.googlegroups.com> (raw)
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
reply other threads:[~2009-06-05 14:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://groups.google.com/group/rack-devel
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=af13daec-08e9-4e08-86cc-3e770ab6740a@s21g2000vbb.googlegroups.com \
--to=rack-devel@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).