Skip to content

Instantly share code, notes, and snippets.

Created December 20, 2012 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4342765 to your computer and use it in GitHub Desktop.
Save anonymous/4342765 to your computer and use it in GitHub Desktop.
package Mojolicious::Lite::GetPost;
use Mojo::Base -base;
use Mojo::Util 'monkey_patch';
sub import {
my $caller = caller;
my $app = $caller->can('app')->();
monkey_patch $caller, 'get_post', sub {
return $app->routes->any([qw(GET POST)], @_);
};
}
1;
use Mojolicious::Lite;
use Mojolicious::Lite::GetPost;
get_post '/' => {text => 'Hello World!'};
app->start;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment