Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # I haven't tested this one, I just want to make sure I've got the concept and structure right.
- my $foo_route = $r->route('/foo')->to(controller => 'Dispatch'); #top level route to hang all others off of
- $foo_route->get->to(action => 'foo_get'); #creates the route GET /foo
- $foo_route->post->to(action => 'foo_post'); #creates the route POST /foo
- my $bar_route = $foo_route->route('/bar'); #implicitly creates /foo/bar, but this'll get clobbered
- # on the next line by the child route. So I'm not going to bother
- # explicitly setting it up as a get.
- $bar_route->get('/baz')->to(action => 'baz'); # creates the route GET /foo/bar/baz
- $bar_route->get('/bing')->to(action => 'baz'); # creates the route GET /foo/bar/bing
- $bar_route->get->to(action => 'bar_get'); # creates the route GET /foo/bar (overridden once we tacked on the children)
- my $zip_route = $bar_route->route('/zip'); # implicitly makes /foo/bar/baz/zip, but this'll get clobbered
- # on the next line by the child route
- $zip_route->get('/adeedoodah')->to(action => 'zippy'); #creates the route /foo/bar/baz/zip/adeedoodah
- $zip_route->get; # explicitly recreates the route GET /foo/bar/baz/zip
- Basically, I think the only thing I was missing was the need to explicitly recreate an existing route once a child route is hung onto it.
- Sound like I've got the right concepts? I'm less concerned about typos in the code, those are easy to fix, I want to make sure I understand how the dispatch setup and mechanics are working.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement