We're updating the issue view to help you get more done. 

Allow router toRedirect() to access variables in original route to pass along.

Description

If a user wants to intercept a route like

1 /user/settings/notifications/123

and redirect it to something like

1 /user/settings/notifications/me/123

using this syntax

1 2 route( "/user/settings/notifications/:usertuid?" ) .toRedirect( target="user/settings/notifications/me/?????" , statusCode=302 );

Find some way to reference the existing rc in the toRedirect() DSL. Perhaps allow the target to be a closure that receives event, rc, and prc.

It's possible to do this right now like so:

1 2 3 route( "/user/settings/notifications/:usertuid" , function( event, rc, prc ) { relocate("/user/settings/notifications/me/#rc.UserTUID#"); } ).end();

but the docs aren't really clear that you can call a redirect in the response closure and it would still be nice to do it via the actual toRedirect() part of the DSL.

Status

Assignee

Luis Majano

Reporter

Brad Wood

Labels

None

Priority

Major