I'd like to have MyMiddleware run in my Rack app, but only for certain paths.  I was hoping to use Rack::Builder or at least Rack::URLMap, but I can't quite figure out how.
This is what I thought would work, but doesn't:
# in my rackup file or Rails environment.rb:
map '/foo' do
  use MyMiddleware, { :some => 'options' }
end
Or, better yet, with a Regexp:
map /^foo/ do
  use MyMiddleware, { :some => 'options' }
end
But map seems to demand an app at the end; it won't fall back on just passing control back to its parent.  (The actual error is "undefined method 'each' for nil:NilClass" from when Rack tries to turn the end of that do...end block into an app.)
Is there a middleware out there that takes an array of middlewares and a path and only runs them if the path matches?