[pmg-devel] [PATCH pmg-api v3 01/10] HTTPServer: extend download functionality
Dominik Csapak
d.csapak at proxmox.com
Thu Oct 10 11:21:52 CEST 2019
allow object as return value for 'download' api calls
this way, we can give additional information for download apis
(like the content-type and if it should be deleted after)
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
changes from v2:
* better error text
src/PMG/HTTPServer.pm | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/PMG/HTTPServer.pm b/src/PMG/HTTPServer.pm
index 6997dd5..8c29059 100755
--- a/src/PMG/HTTPServer.pm
+++ b/src/PMG/HTTPServer.pm
@@ -162,9 +162,13 @@ sub rest_handler {
};
if ($info->{download}) {
- die "download methods should have return type 'string' - internal error"
- if ($info->{returns}->{type} ne 'string');
- $resp->{download} = $result;
+ my $type = $info->{returns}->{type};
+ if ($type eq 'string' || $type eq 'object') {
+ $resp->{download} = $result;
+ } else {
+ die "API calls which trigger downloads need to have return type 'string' or 'object' - internal error"
+ }
+
} else {
$resp->{data} = $result;
}
--
2.20.1
More information about the pmg-devel
mailing list