[Nitro] "magic" mapping of controllers possible?

Lars Olsson lasso at lassoweb.se
Wed Jun 21 14:21:35 EDT 2006


Hi list!

When mapping multiple controllers (via Nitro::Server.map) all Controller 
classes has to be loaded/required before I put them in the map. To my 
understanding this means that even if I only visit a particular url 
(/foo) Nitro still have to load both the DefaultController and the 
BarController. Is this correct?

# sample run.rb
require 'nitro'

class DefaultController
     def index
         "DefaultController"
     end
end

class FooController
     def index
         "FooController"
     end
end

class BarController
     def index
         "BarController"
     end
end

Nitro::Server.map =
     {
         '/' => DefaultController,
         '/foo' => FooController,
         '/bar' => BarController
     }

Nitro.run
# end sample

Is it in any way possible to create a "magic" map that maps the request 
name to a partical controller, i.e:

"/" maps to controllers/DefaultController (special case)
"/foo" maps to controllers/FooController
"/bar" maps to controllers/BarController
"/baz" maps to controllers/BazController
# you get the idea...

Kindly

/Lasso


-- 
________________________________________
Lars Olsson
lasso at lassoweb.se
http://www.lassoweb.se/



More information about the Nitro-general mailing list