hi all, I want to move some routing tasks out of the router and into the controller. The goal is to make Merb feel less like mod_rewrite and give the user more control at the controller. The new Router is simple: it takes the path_info (not the whole request) then outputs a controller class and some parameters from the path matching. The rest of the routing would be done at the controller level. The controller is ultimately in charge of determining which action to call. In particular, only the controller gets to see the http method.
Because resource controllers and normal controllers have very different routing rules, I think they should be different classes. I'd split them into two classes: Merb::Controllers::Standard and Merb::Controllers::Resource. These would both be subclasses of Controller, and would implement the method Controller#route Users would create controllers by subclassing one of these two. Some cute things can be done by letting the controller have control of action routing. For example, in the standard controller we could use punctuation to declare that an action receives a POST: def update! # POST controller/update def update # GET controller/update def index # GET controller/index The standard controller can safely ignore _method (for those of us who do not want emulated PUT and DELETE methods) We can put custom route rules nearer to the actions they effect instead of in a separate file. add_route 'test/:blah', :index # assigns params[:blah] and routes to test action def test end Duane's popular regular expression routing can be implemented in an add_route-like controller class method, say, match_route. In the end this will be a tighter, more readable, and more natural API than the current. Additionally this opportunity can be used to rid Merb of the increasingly complex @compiled_statement construction in route.rb and rely instead on a constructed data structure to match against. I suspect performance can be increased. This is a largish change and I would like to create it in an experimental branch to work on it. Thoughts? ry _______________________________________________ Merb-devel mailing list [email protected] http://rubyforge.org/mailman/listinfo/merb-devel
