mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-08 14:38:47 +00:00
allow endpoint specific maps
This commit is contained in:
parent
d7be64c3d9
commit
3f17618ad5
2 changed files with 13 additions and 10 deletions
|
@ -2,7 +2,7 @@ import getServiceWidget from "utils/service-helpers";
|
|||
import { formatApiCall } from "utils/api-helpers";
|
||||
import { httpProxy } from "utils/http";
|
||||
|
||||
export default async function genericProxyHandler(req, res, mapper) {
|
||||
export default async function genericProxyHandler(req, res, maps) {
|
||||
const { group, service, endpoint } = req.query;
|
||||
|
||||
if (group && service) {
|
||||
|
@ -24,8 +24,8 @@ export default async function genericProxyHandler(req, res, mapper) {
|
|||
});
|
||||
|
||||
let resultData = data;
|
||||
if (mapper) {
|
||||
resultData = mapper(endpoint, data);
|
||||
if (maps[endpoint]) {
|
||||
resultData = maps[endpoint](data);
|
||||
}
|
||||
|
||||
if (contentType) res.setHeader("Content-Type", contentType);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue