mirror of
https://git.proxmox.com/git/pve-common
synced 2025-08-05 09:31:02 +00:00
new helper register_page_formater
This commit is contained in:
parent
844a246d44
commit
15a4dae162
@ -235,6 +235,31 @@ sub register_method {
|
||||
push @{$method_registry->{$self}}, $info;
|
||||
}
|
||||
|
||||
sub register_page_formater {
|
||||
my ($self, %config) = @_;
|
||||
|
||||
my $format = $config{format} ||
|
||||
die "missing format";
|
||||
|
||||
my $path = $config{path} ||
|
||||
die "missing path";
|
||||
|
||||
my $method = $config{method} ||
|
||||
die "missing method";
|
||||
|
||||
my $code = $config{code} ||
|
||||
die "missing formater code";
|
||||
|
||||
my $uri_param = {};
|
||||
my ($handler, $info) = $self->find_handler($method, $path, $uri_param);
|
||||
die "unabe to find handler for '$method: $path'" if !($handler && $info);
|
||||
|
||||
die "duplicate formater for '$method: $path'"
|
||||
if $info->{formater} && $info->{formater}->{$format};
|
||||
|
||||
$info->{formater}->{$format} = $code;
|
||||
}
|
||||
|
||||
sub AUTOLOAD {
|
||||
my ($this) = @_;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user