-
-
Save yko/8160dba7492bd018fbcb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple "resource" keyword | |
$r->add_keyword(resource => sub { | |
my ($r, $name) = @_; | |
# Generate "/$name" route | |
my $resource = $r->route("/$name")->to("$name#"); | |
# Handle POST requests | |
$resource->bridge->to(cb => sub { shift->can_i_haz }) | |
->post->to('#create')->name("create_$name"); | |
# Handle GET requests | |
$resource->get->to('#show')->name("show_$name"); | |
return $resource; | |
}); | |
# POST /user -> {controller => 'user', action => 'create'} | |
# GET /user -> {controller => 'user', action => 'show'} | |
$r->resource('user'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment