Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2013
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. # I haven't tested this one, I just want to make sure I've got the concept and structure right.
  2.  
  3. my $foo_route = $r->route('/foo')->to(controller => 'Dispatch'); #top level route to hang all others off of
  4.  
  5. $foo_route->get->to(action => 'foo_get'); #creates the route GET /foo
  6. $foo_route->post->to(action => 'foo_post'); #creates the route POST /foo
  7. my $bar_route = $foo_route->route('/bar'); #implicitly creates /foo/bar, but this'll get clobbered
  8. # on the next line by the child route. So I'm not going to bother
  9. # explicitly setting it up as a get.
  10. $bar_route->get('/baz')->to(action => 'baz'); # creates the route GET /foo/bar/baz
  11. $bar_route->get('/bing')->to(action => 'baz'); # creates the route GET /foo/bar/bing
  12. $bar_route->get->to(action => 'bar_get'); # creates the route GET /foo/bar (overridden once we tacked on the children)
  13. my $zip_route = $bar_route->route('/zip'); # implicitly makes /foo/bar/baz/zip, but this'll get clobbered
  14. # on the next line by the child route
  15. $zip_route->get('/adeedoodah')->to(action => 'zippy'); #creates the route /foo/bar/baz/zip/adeedoodah
  16. $zip_route->get; # explicitly recreates the route GET /foo/bar/baz/zip
  17.  
  18. 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.
  19.  
  20. 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