Created
December 20, 2012 03:43
-
-
Save kraih/4342795 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package Mojolicious::Lite::GetPost; | |
use Mojo::Base -base; | |
use Mojo::Util 'monkey_patch'; | |
sub import { | |
my $caller = caller; | |
monkey_patch $caller, 'get_post', sub { | |
return $caller->app->routes->any([qw(GET POST)] => @_); | |
}; | |
} | |
1; |
This file contains hidden or 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
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
Kinda useful, vote for it to be in a cookbook