module Proximity
Constants
- RoutingError
- VERSION
Public Class Methods
included(base)
click to toggle source
# File lib/proximity.rb, line 12 def self.included(base) base.extend ClassMethods end
Public Instance Methods
call(env)
click to toggle source
Calls superclass method
# File lib/proximity.rb, line 22 def call(env) route_env(env) super rescue RoutingError => e headers = {'Content-Type' => 'text/plain', 'Content-Length' => e.message.length} [404, headers, [e.message]] end
route(env)
click to toggle source
# File lib/proximity.rb, line 43 def route(env) match = router.match(env) if match uri = URI.parse(match.target) [uri.host, uri.path] else raise RoutingError.new("The path: #{env['PATH_INFO']} does not match any proxy routes.") end end
route_env(env)
click to toggle source
# File lib/proximity.rb, line 30 def route_env(env) host, path = route(env) env.tap { |e| e['SCRIPT_NAME'] = '' e['HTTP_HOST'] = host e['PATH_INFO'] = path } end
router()
click to toggle source
# File lib/proximity.rb, line 39 def router self.class.routes.router end