kwakwaversal / mojolicious-plugin-restify

Route shortcuts & helpers for REST collections - https://metacpan.org/pod/Mojolicious::Plugin::Restify

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simplify the creation of collections

kwakwaversal opened this issue · comments

For most use cases, a user will just want to create collections with no special configuration.

Rather than using a hash (quite flexible).

my $restify_routes = {
  # /area-codes
  #   /area-codes/:area_codes_id/numbers
  'area-codes' => {
    'numbers' => undef
  },
  # /news
  'news' => undef,
  # /payments
  'payments' => [undef, {over => 'int'}],
  # /users
  #   /users/:users_id/messages
  #     /users/:users_id/messages/:messages_id/recipients
  'users' => {
    'messages' => {
      'recipients' => undef
    }
  },
};
 
$self->restify->routes($self->routes, $restify_routes, {over => 'uuid'});

Look into simplifying it using an array.

my $restify_routes = [
  'area-codes', 'area-codes/numbers',
  'news',
  'payments',
  'users', 'users/messages', 'users/messages/recipients'
];

$self->restify->routes($self->routes, $restify_routes, {over => 'uuid'});