views:

21

answers:

0

Lets say I'm writing a sinatra extension which mounts a second public directory at a given mount point.

require 'sinatra'
require 'sinatra/moar-public'

set :moar_local, './downloads/'
set :moar_remote, 'dls'

I now expect a user going to http://myapp.com/downloads/thing.bin to be given the file at [sinatra_root]/dls/thing.bin.

Writing this extension (obviously, it's a simplified example) I have something like this:

require 'sinatra/base'
module Sinatra
  module MoarPublic
    def self.registered(app)
      app.set :moar_local, './downloads/'
      app.set :moar_remote, 'downloads'

      app.get "/#{app.options.moar_remote}/:filename" do
        # Logic
      end
    end
  end
  register MoarPublic
end

But app.get has already been called with the default value for moar_remote so the download files are available at /downloads/thing.bin, not at /dls/thing.bin as I'd like. Any ideas?