From: Dominik Csapak Date: Fri, 15 Jun 2018 13:28:42 +0000 (+0200) Subject: add the possibility to use a hash for parameter mapping X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=commitdiff_plain;h=a1c7eddaf198b1fb23255f0199c0624476a35606;hp=305fc1e12a1482eed19fc65cbea1b78e4f79cf7d add the possibility to use a hash for parameter mapping instead of writing: ['name', sub {...}, 'description', 1] one can now use: { name => 'name', func => sub { ... }, desc => 'desc', interactive => 1, } which makes it more obvious what is what (and allows later patches to easily override some things) Signed-off-by: Dominik Csapak --- diff --git a/src/PVE/RESTHandler.pm b/src/PVE/RESTHandler.pm index 50c37c2..61dee20 100644 --- a/src/PVE/RESTHandler.pm +++ b/src/PVE/RESTHandler.pm @@ -553,6 +553,10 @@ my $compute_param_mapping_hash = sub { my ($name, $func, $desc, $interactive); if (ref($item) eq 'ARRAY') { ($name, $func, $desc, $interactive) = @$item; + } elsif (ref($item) eq 'HASH') { + # just use the hash + $res->{$item->{name}} = $item; + next; } else { $name = $item; $func = sub { return PVE::Tools::file_get_contents($_[0]) };