From 5dbe1cf80d14bbc620f955f0fc6faf411cc848f2 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 17 Aug 2024 23:43:21 +0800 Subject: [PATCH] :sparkles: Support services aliasing --- pkg/internal/server/api/directory.go | 6 ++++++ settings.toml | 3 +++ 2 files changed, 9 insertions(+) diff --git a/pkg/internal/server/api/directory.go b/pkg/internal/server/api/directory.go index 076e9bc..00205be 100644 --- a/pkg/internal/server/api/directory.go +++ b/pkg/internal/server/api/directory.go @@ -1,6 +1,7 @@ package api import ( + "github.com/spf13/viper" "strings" "git.solsynth.dev/hydrogen/dealer/pkg/internal/directory" @@ -25,6 +26,11 @@ func listExistsService(c *fiber.Ctx) error { func forwardServiceRequest(c *fiber.Ctx) error { serviceType := c.Params("service") + aliasingMap := viper.GetStringMapString("services.alias") + if val, ok := aliasingMap[serviceType]; ok { + serviceType = val + } + service := directory.GetServiceInstanceByType(serviceType) if service == nil || service.HttpAddr == nil { diff --git a/settings.toml b/settings.toml index 8bc7901..474475d 100644 --- a/settings.toml +++ b/settings.toml @@ -36,3 +36,6 @@ cookie_samesite = "Lax" access_token_duration = 300 refresh_token_duration = 2592000 +[services] +alias = { id = "auth", uc = "files", co = "interactive", im = "messagings" } +