NAME
Terse::Controller - controllers made simple.
VERSION
Version 0.111
SYNOPSIS
package Stocks;
use base 'Terse::Controller';
sub login :any {
return 1;
}
sub auth_prevent :any(auth) {
return 0;
}
sub auth :get :post {
return $_[1]->delayed_response(sub { ... });;
}
sub purchase :get :delayed { # delayed attribute is the same as the above
... #1
}
sub purchase_virtual :get(purchase) :params(virtual => 1) {
... #2
}
sub purchase_post :post(purchase) {
... # 3
}
sub purchase_virtual_post :post(purchase) :params(virtual => 1) {
... # 4
}
sub other :get :path(foo/(.*)/bar) :captured(1) {
... # 5
}
1;
.... psgi ...
use Terse;
use Stocks;
our $api = Stocks->new();
sub {
my ($env) = (shift);
Terse->run(
plack_env => $env,
application => $api,
);
};
....
plackup Stocks.psgi
GET http://localhost:5000/?req=purchase #1
POST http://localhost:5000/ {"req":"purchase"} #3
GET http://localhost:5000/?req=purchase&virtual=1 #2
POST http://localhost:5000/ {"req":"purchase", "virtual":1} #4
GET http://localhost:5000/foo/555/bar #5
AUTHOR
LNATION, <email at lnation.org>