Mojolicious-Plugin-Restify

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


  sub read {
    my $c = shift;

    # account was placed in the stash in the resource_lookup action
    $c->render(json => $c->stash('account'));
  }

  sub patch { ... }

  sub update { ... }

  1;
```

[Mojolicious::Plugin::Restify](https://metacpan.org/release/Mojolicious-Plugin-Restify)
is a [Mojolicious::Plugin](https://metacpan.org/pod/Mojolicious::Plugin). It
simplifies generating all of the
[Mojolicious::Routes](https://metacpan.org/pod/Mojolicious::Routes) for a
typical REST *collection* endpoint (e.g., `/accounts` or `/invoices>` and maps
the common HTTP verbs (`DELETE`, `GET`, `PATCH`, `POST`, `PUT>` to underlying

lib/Mojolicious/Plugin/Restify.pm  view on Meta::CPAN


  sub read {
    my $c = shift;

    # account was placed in the stash in the resource_lookup action
    $c->render(json => $c->stash('account'));
  }

  sub patch { ... }

  sub update { ... }

  1;

=head1 DESCRIPTION

L<Mojolicious::Plugin::Restify> is a L<Mojolicious::Plugin>. It simplifies
generating all of the L<Mojolicious::Routes> for a typical REST I<collection>
endpoint (e.g., C</accounts> or C</invoices>) and maps the common HTTP verbs
(C<DELETE>, C<GET>, C<PATCH>, C<POST>, C<PUT>) to underlying controller class
methods.

t/restify.t  view on Meta::CPAN

  my ($self, $msg) = @_;
  my $id = $self->stash($self->name . '_id') // '';
  $self->render(text => "$msg,$id");
}

sub resource_lookup {1}
sub create          { shift->catchall('create') }
sub delete          { shift->catchall('delete') }
sub list            { shift->catchall('list') }
sub read            { shift->catchall('read') }
sub update          { shift->catchall('update') }

sub name {
  my $self = shift;
  my $name = $self->stash->{controller};
  $name =~ s,^.*\-,,;
  return $name;
}

1;

t/synopsis.t  view on Meta::CPAN

  my ($self, $msg) = @_;
  my $id = $self->stash($self->name . '_id') // '';
  $self->render(text => "$msg,$id");
}

sub resource_lookup {1}
sub create          { shift->catchall('create') }
sub delete          { shift->catchall('delete') }
sub list            { shift->catchall('list') }
sub read            { shift->catchall('read') }
sub update          { shift->catchall('update') }

sub name {
  my $self = shift;
  my $name = $self->stash->{controller};
  $name =~ s,^.*?\-,,;
  return $name;
}

1;



( run in 0.471 second using v1.01-cache-2.11-cpan-e5176c747c2 )