Glances info widget

This commit is contained in:
Michael Shamoon 2022-10-10 11:18:29 -07:00
parent 5198b056cc
commit 321efd08cc
4 changed files with 140 additions and 0 deletions

View file

@ -0,0 +1,23 @@
import { httpProxy } from "utils/proxy/http";
export default async function handler(req, res) {
const { url } = req.query;
if (!url) {
return res.status(400).json({ error: "Missing Glances URL" });
}
const apiUrl = `${url}/api/3/quicklook`;
const params = { method: "GET", headers: {
"Accept-Encoding": "application/json"
} };
const [status, contentType, data, responseHeaders] = await httpProxy(apiUrl, params);
if (status !== 200) {
logger.error("HTTP %d getting data from glances API %s. Data: %s", status, apiUrl, data);
}
if (contentType) res.setHeader("Content-Type", contentType);
return res.status(status).send(data);
}