I have a Rails 2.3.12 app that is fronting for another application. Call the other application foo; all URIs sent to my app will begin with /foo. My Rails app needs to handle these cases:
GET /foo— my app handles directly (returns a list of what’s supported)<anything-else> /foo— returns a 401 (i.e.,GETis the only supported HTTP verb)<anything> /foo/<anything>— gets handled by my app to be passed to thefooapp.
Unfortunately, all of my attempts so far have resulted in everything being fielded by either cases 1&2 or by case 3. Here’s what I have in my routes.rb at the moment:
map.root(:controller => 'application',
:action => 'render_401_unauthorised')
map.connect('fooapp/*fooapp_ep_path',
:controller => 'foo',
:action => 'parsepath')
map.connect('fooapp',
:controller => 'other_controller',
:action => 'index',
:conditions => { :method => :get })
map.connect('fooapp',
:controller => 'application',
:action => 'render_401_unauthorised')
I think my problem would go away if I could ensure that the first map.connect would only match if *fooap_ep_path isn’t empty — i.e., matches the regex %r!/foo/.+!
Can this be done?
Thanks!
Updated If there is any way to specify that a glob path must be [non]empty, that would probably provide the necessary glue.
I worked this out using
#with_optionsalong the lines of