Skip to content

Instantly share code, notes, and snippets.

@notbenh
Created November 11, 2011 03:06
Show Gist options
  • Save notbenh/1357079 to your computer and use it in GitHub Desktop.
Save notbenh/1357079 to your computer and use it in GitHub Desktop.
How do I do a get/post subdispatch with dancer
package Thing::App;
use Dancer ':syntax';
sub get_my_data {...};
any ['get', 'post'] => '/something' => sub {
my $data = get_my_data();
if (request->method eq 'GET') {
...
} else {
...
}
};
get '/something/else' => sub{
my $data = get_my_data();
...
};
post '/something/else' => sub{
my $data = get_my_data();
...
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment