Skip to content

Instantly share code, notes, and snippets.

@amarburg
Created November 27, 2011 22:42
Show Gist options
  • Save amarburg/1398333 to your computer and use it in GitHub Desktop.
Save amarburg/1398333 to your computer and use it in GitHub Desktop.
Mogile proxy in Rails3
module AerialImageDb
class Application < Rails::Application
# ...snip...
# Custom directories with classes and modules you want to be autoloadable.
config.autoload_paths += %W(#{config.root}/lib)
# ...snip...
end
end
require 'mogproxy/mogproxy'
require 'sinatra/base'
module MogProxy
class Server < Sinatra::Base
include MogileModule::Mogilable
configure(:production, :development) do
enable :logging
end
get %r{/([\w\d\/_]+)} do
path = '/' + params[:captures].join
begin
logger.info "MogProxy fetching mog path #{path}"
mog.get( path )
rescue
logger.info "Mogproxy: Hm, problem fetching #{path}"
raise Sinatra::NotFound
end
end
end
end
mount MogProxy::Server, :at => "/mogproxy"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment