Sha256: 113d6bda772b54444b1fe8d38ba58ad520e800c036c8f650d4715886d16936e9
Contents?: true
Size: 1021 Bytes
Versions: 2
Compression:
Stored size: 1021 Bytes
Contents
require 'nitro/dispatcher' module Nitro # Specialize the Dispatcher to handle implicit 'nice' urls. class Dispatcher # An alternative dispatching algorithm that handles # implicit nice urls. Subdirectories are not supported. # # Returns the dispatcher class, the action name and the # base url. For the root path, the base url is nil. def dispatch(path, context) path = route(path, context) parts = path.split('/') parts.shift # get rid of the leading '/'. if klass = controller_class_for("/#{parts.first}") base = "/#{parts.shift}" else base = nil klass = controller_class_for(ROOT) end unless action = parts.shift action = 'index' end unless parts.empty? context.headers['QUERY_STRING'] = "#{parts.join(';')};#{context.headers['QUERY_STRING']}" end base = nil if base == ROOT return klass, "#{action}_action", base end end Dispatcher.mode = :nice end # * George Moschovitis <gm@navel.gr>
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.23.0 | lib/nitro/dispatcher/nice.rb |
nitro-0.24.0 | lib/nitro/dispatcher/nice.rb |