Hi~
On Sep 17, 2007, at 6:14 PM, ry dahl wrote:
> 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
I'm not convinced that this would make things better. You're welcome
to work on a branch but I'm not going to merge it to trunk unless I
think it's a big improvement and I'm not seeing why this way would be
better. I also don't like the idea of two different types of
controllers that are exactly the same and inherit from the same
superclass but are different only in how they are routed to.
I don't want to discourage you from trying this out in a branch so
go for it, but I have to reserve judgement until I see it or you show
me a more complete mockup API.
Cheers-
-- Ezra Zygmuntowicz
-- Founder & Ruby Hacker
-- [EMAIL PROTECTED]
-- Engine Yard, Serious Rails Hosting
-- (866) 518-YARD (9273)
_______________________________________________
Merb-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/merb-devel