Mojolicious-Plugin-Restify
view release on metacpan or search on metacpan
767778798081828384858687888990919293949596
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
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
324325326327328329330331332333334335336337338339340341342343344
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
56789101112131415161718192021222324
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
56789101112131415161718192021222324
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.314 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )