HI Stefan,

i guess my post was not clear on a specific part, from the documentation, 
for instance, that link 
http://mojolicious.org/perldoc/Mojolicious/Guides/Routing#Special-stash-values 
, i see that stash values action and controller are used instantiating the 
controller class, however, when setting those values in the stash, it does 
not change the controller that is used, except if it is set within route 
placeholder.

By checking code of Mojolicious/Routes.pm and Mojolicious/Routes/Match.pm , 
it seems that controller and action are not taken from the stash, they are 
only taken the match object, so from the route match itself and captures. 

That is the part where i am not sure to understand correctly, documentation 
says that action and controller are special value of the stash, and that 

When the dispatcher sees controller and action values in the stash it will 
always try to turn them into a class and method to dispatch to.

However, setting controller and action in the stash before the dispatcher 
kicks in does not change the routing. From the code, values are not taken 
from the stash, there are taken from the route match, first from the 
captures of the route, and then from the to method, but they are not taken 
from the stash.

Am i missing something?

Pierre
​

On Sunday, May 7, 2017 at 1:12:21 AM UTC+8, Stefan Adams wrote:
>
>
> On Fri, May 5, 2017 at 5:36 AM, Pierre VIGIER <[email protected] 
> <javascript:>> wrote:
>
>> Am i getting something wrong? That was not my understanding from the 
>> documentation.
>
>
> $r->get('/in_url/:controller/:action')->to( controler => 'first', action 
> => 'fallback' );
>
> I'm pretty sure that according to the optional placeholders documentation 
> you wouldn't set controller and action in to(). Basically, you're able to 
> skip the to() because you've already set the controller and action in your 
> route (:controller stashes that part of the path into the reserved stash 
> value controller, and likewise for action). So you should be doing this, I 
> think:
>
> $r->get('/in_url/:controller/:action');
>
> And that will route appropriately for a GET request to, e.g., 
> /in_url/first/fallback
>
> So if'm right and if you're misunderstanding the documentation, then 
> perhaps the rest of your question is moot until you try with this new 
> interpretation. Let us know!
>
> And yes, I think to() overrides the stash.
>
> In the end, I don't think there's anything strange except that you're 
> using the :controller / :action trick yet declaring them explicitly with 
> to().
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to