Merge branch 'top-level-links'

This commit is contained in:
Yanick Champoux 2023-10-31 16:30:14 -04:00
commit d7e7c7447c
2 changed files with 12 additions and 0 deletions

View File

@ -58,6 +58,14 @@ $registry->add_type(
count => $xtra->{count}, count => $xtra->{count},
total => 0+ @$data, total => 0+ @$data,
} }
},
top_level_links => {
self => '/articles',
},
links => {
self => sub($data,@) {
return "/articles/" . $data->{id};
},
} }
} }
); );
@ -72,6 +80,9 @@ like $output => {
"count"=> 2, "count"=> 2,
"total"=> 1 "total"=> 1
}, },
"links"=> {
"self"=> "/articles"
},
}; };
done_testing(); done_testing();

View File

@ -11,6 +11,7 @@ $registry->add_type(
id => 'id', id => 'id',
links => { links => {
self => sub ( $data, @ ) { self => sub ( $data, @ ) {
no warnings qw/ uninitialized /;
return "/peoples/$data->{id}"; return "/peoples/$data->{id}";
} }
} } ); } } );