Created
November 27, 2011 22:42
-
-
Save amarburg/1398333 to your computer and use it in GitHub Desktop.
Mogile proxy in Rails3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mount MogProxy::Server, :at => "/mogproxy" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment