}
my $csrfgen_func = $self->can('generate_csrf_prevention_token');
- my ($raw, $ct, $nocomp) = &$formatter($res, $res->{data}, $params, $path, $auth, $csrfgen_func);
+ my ($raw, $ct, $nocomp) = &$formatter($res, $res->{data}, $params, $path,
+ $auth, $csrfgen_func, $self->{title});
my $resp;
if (ref($raw) && (ref($raw) eq 'HTTP::Response')) {
$self->{cookie_name} //= 'PVEAuthCookie';
$self->{base_uri} //= "/api2";
$self->{dirs} //= {};
+ $self->{title} //= 'API Inspector';
my $base = '/usr/share/libpve-http-server-perl';
add_dirs($self->{dirs}, '/css/' => "$base/css/");
my $login_url = "$baseurl/access/ticket";
sub render_page {
- my ($doc, $html) = @_;
+ my ($doc, $html, $title) = @_;
my $items = [];
}};
- my $title = "Proxmox VE";
-
my $nav = $doc->el(
class => "navbar navbar-inverse navbar-fixed-top",
role => "navigation", cn => {
});
PVE::APIServer::Formatter::register_formatter($portal_format, sub {
- my ($res, $data, $param, $path, $auth, $csrfgen_func) = @_;
+ my ($res, $data, $param, $path, $auth, $csrfgen_func, $title) = @_;
# fixme: clumsy!
PVE::APIServer::Formatter::Standard::prepare_response_data($portal_format, $res);
$data = $res->{data};
my $html = '';
- my $doc = PVE::APIServer::Formatter::Bootstrap->new($res, $path, $auth, $csrfgen_func);
+ my $doc = PVE::APIServer::Formatter::Bootstrap->new($res, $path, $auth, $csrfgen_func, $title);
if (!HTTP::Status::is_success($res->{status})) {
$html .= $doc->alert(text => "Error $res->{status}: $res->{message}");
$html = $doc->el(class => 'container', html => $html);
- my $raw = render_page($doc, $html);
+ my $raw = render_page($doc, $html, $title);
return ($raw, $portal_ct);
});
method => 'GET',
path => "/access/ticket",
code => sub {
- my ($res, $data, $param, $path, $auth, $csrfgen_func) = @_;
+ my ($res, $data, $param, $path, $auth, $csrfgen_func, $title) = @_;
- my $doc = PVE::APIServer::Formatter::Bootstrap->new($res, $path, $auth, $csrfgen_func);
+ my $doc = PVE::APIServer::Formatter::Bootstrap->new($res, $path, $auth, $csrfgen_func, $title);
my $html = &$login_form($doc);
- my $raw = render_page($doc, $html);
+ my $raw = render_page($doc, $html, $title);
return ($raw, $portal_ct);
});
method => 'POST',
path => "/access/ticket",
code => sub {
- my ($res, $data, $param, $path, $auth, $csrfgen_func) = @_;
+ my ($res, $data, $param, $path, $auth, $csrfgen_func, $title) = @_;
if (HTTP::Status::is_success($res->{status})) {
my $cookie = PVE::APIServer::Formatter::create_auth_cookie(
# Note: HTTP server redirects to 'GET /access/ticket', so below
# output is not really visible.
- my $doc = PVE::APIServer::Formatter::Bootstrap->new($res, $path, $auth, $csrfgen_func);
+ my $doc = PVE::APIServer::Formatter::Bootstrap->new($res, $path, $auth, $csrfgen_func, $title);
my $html = &$login_form($doc);
- my $raw = render_page($doc, $html);
+ my $raw = render_page($doc, $html, $title);
return ($raw, $portal_ct);
});