Reputation: 2054
(I believe this is doable, but just googling around, I haven't found any examples of it.)
Perhaps a more concrete example of what I'm asking. Suppose I have rails-3 apps already written: Foo, Bar, Baz, Qux. I have another application written: Master. Within Master I want to match routes and run the other apps in it. Since they are all rack-compatible, I imagine the routing in master would be something like this:
match "/foo" => Foo::Application
match "/bar" => Bar::Application
match "/baz" => Baz::Application
match "/qux" => Qux::Application
but I haven't figured out how to do it and where to actually put the code for the apps relative to the master app.
Upvotes: 0
Views: 222
Reputation: 17257
You probably want to catch things earlier than routing in the master application.
You can do this by going lower-level in to Rack; the Rack configuration file in the root of your Rails app called config.ru:
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Rack::URLMap.new \
"/" => Master::Application,
"/foo" => Foo::Application,
"/bar" => Bar::Application
# ... etc.
You can read more about Rack::URLMap here.
Upvotes: 2