server/config: add mechanism to update template

instead of exposing handlebars itself, offer a register_template and
a render_template ourselves.

render_template checks if the template file was modified since
the last render and reloads it when necessary

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak
2020-07-21 11:10:36 +02:00
committed by Thomas Lamprecht
parent 27fde64794
commit 2ab5acac5a
3 changed files with 70 additions and 16 deletions

View File

@ -1,5 +1,5 @@
use std::sync::Arc;
use std::path::Path;
use std::path::{Path, PathBuf};
use anyhow::{bail, format_err, Error};
use futures::*;
@ -53,6 +53,10 @@ async fn run() -> Result<(), Error> {
config.add_alias("css", "/usr/share/javascript/proxmox-backup/css");
config.add_alias("docs", "/usr/share/doc/proxmox-backup/html");
let mut indexpath = PathBuf::from(buildcfg::JS_DIR);
indexpath.push("index.hbs");
config.register_template("index", &indexpath)?;
let rest_server = RestServer::new(config);
//openssl req -x509 -newkey rsa:4096 -keyout /etc/proxmox-backup/proxy.key -out /etc/proxmox-backup/proxy.pem -nodes