Skip to content

Instantly share code, notes, and snippets.

@jjn1056
Created August 7, 2023 16:28
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 jjn1056/697692b7c4218754c8d9f87150d18f26 to your computer and use it in GitHub Desktop.
Save jjn1056/697692b7c4218754c8d9f87150d18f26 to your computer and use it in GitHub Desktop.
use Moose;
use MooseX::MethodAttributes;
use Example::Syntax;
class Example::Controller::Account :isa(Example::Controller) {
sub root :At('$path_end/...') Via('../protected') ($self, $c, $user) {
$c->action->next($user->account);
}
sub prepare_edit :At('...') Via('root') ($self, $c, $account) {
$self->view_for('edit', account => $account);
$c->action->next($account);
}
sub edit :Get('edit') Via('prepare_edit') ($self, $c, $account) {
return $c->view->set_http_ok;
}
sub update :Patch('') Via('prepare_edit') BodyModel ($self, $c, $account, $bm) {
return $account->update_account($bm) ?
$c->view->set_http_ok :
$c->view->set_http_bad_request;
}
}
__PACKAGE__->meta->make_immutable;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment