Return the Route
that corresponds to the given request
.
# File lib/mongrel2/config/route.rb, line 22
def self::for_request( request )
pattern = request.headers.pattern
self.log.debug "Searching for the route for the path %p in %p" %
[ pattern, self.all ]
return self.filter( path: pattern ).first
end
The Mongrel2::Config::Host
this route belongs to.
# File lib/mongrel2/config/route.rb, line 36
many_to_one :host
Fetch the route's target, which is either a Mongrel2::Config::Directory
, Mongrel2::Config::Proxy
, or Mongrel2::Config::Handler
object.
# File lib/mongrel2/config/route.rb, line 41
def target
case self.target_type
when 'dir'
return Mongrel2::Config::Directory[ self.target_id ]
when 'proxy'
return Mongrel2::Config::Proxy[ self.target_id ]
when 'handler'
return Mongrel2::Config::Handler[ self.target_id ]
else
raise ArgumentError, "unknown target type %p" % [ self.target_type ]
end
end
Set the target of the route to object
, which should be one of the classes returned from target
.
# File lib/mongrel2/config/route.rb, line 57
def target=( object )
case object
when Mongrel2::Config::Directory
self.target_type = 'dir'
when Mongrel2::Config::Proxy
self.target_type = 'proxy'
when Mongrel2::Config::Handler
self.target_type = 'handler'
else
raise ArgumentError, "unknown target type %p" % [ object.class ]
end
self.target_id = object.id
end