0

I'm trying to do something like this:

class Dispatcher < Sinatra::Base
  def initialize
    @foo = Foo.new
  end

  get '/foo/*' do 
    @foo.call(params[:splat])
  end
end

So that URL /foo/abc/def?xxx=yyy would be like calling the Foo app with /abc/def?xxx=yyy.

This seems like it should be easy, but I haven't seen any example of it.

Mathieu Longtin
  • 15,922
  • 6
  • 30
  • 40

2 Answers2

1

I ended up doing this in a Rack config.ru file:

map "/abc" do
  run Foo.new('abc')
end

map "/def" do
  run Foo.new('def')
end

Not exactly what I wanted, but saves me from modifying the underlying app.

Mathieu Longtin
  • 15,922
  • 6
  • 30
  • 40
0

I'm not sure why you would use Sinatra for that. If I understand you right, and you use Apache with Proxy-Rewrite rules you just do:

The .htaccess file

RewriteEngine On
RewriteRule ^foo/(.*) http://localhost:61000/$1 [P]

So all your domain.tdl/foo get redirected to your local running app athttp://localhost:61000/ with all Post and Get Parameters.

Sir l33tname
  • 4,026
  • 6
  • 38
  • 49
  • I was trying to avoid shoving that in Apache. Basically, I have an app that I need to run 3-10 instances with slightly different config, and I didn't want to run one Vegas process for each. – Mathieu Longtin Oct 25 '13 at 13:19