Hacker News new | ask | show | jobs
by dana_janssen 5217 days ago
Are you able to provide more detail on how something like this would be set up?
3 comments

Rails 3.0 just does this; given a FooApp Sinatra object, yo can match "/foo" :to => FooApp.
Also doable without rails:

  # In config.ru
  # App, V0, and Resque::Server are each sinatra apps
  run Rack::URLMap.new({
    "/"       => App.new,
    "/v0"     => V0.new,
    "/resque" => Resque::Server.new,
  })
Any app built on Rack (which includes Rails, Sinatra, and many other Ruby frameworks) can be mounted this way. See http://guides.rubyonrails.org/routing.html#routing-to-rack-a...
We use Unicorn, which provides a Rack handler for Rails 2.2 apps. I just mounted the an API router app before the Rails handler in our config.ru. The API router app is just a big regex that looks for API related urls, or passes through to Rails. Though, jnunemaker recently showed me a trick where you can mount Sinatra apps in other Sinatra apps through `#use` (like any Middleware). I may try that out and get away from my ghetto regex routes.

We recently upgraded to Rails 2.3 which is built on Rack. `ActionController::Dispatcher.new` is the last Rack app on the stack now.