From 82305206b0ed7de9d0093961891794c9a8111b92 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 27 Jul 2024 01:10:26 +0800 Subject: [PATCH] :sparkles: Status checker endpoint --- pkg/internal/server/api/directory.go | 4 ++++ pkg/internal/server/api/index.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/pkg/internal/server/api/directory.go b/pkg/internal/server/api/directory.go index 292d9ba..076e9bc 100644 --- a/pkg/internal/server/api/directory.go +++ b/pkg/internal/server/api/directory.go @@ -33,7 +33,11 @@ func forwardServiceRequest(c *fiber.Ctx) error { ogUrl := c.Request().URI().String() url := c.OriginalURL() + prevUrl := url url = strings.Replace(url, "/srv/"+serviceType, "/api", 1) + if prevUrl == url { + url = strings.Replace(url, "/cgi/"+serviceType, "/api", 1) + } url = "http://" + *service.HttpAddr + url log.Debug(). diff --git a/pkg/internal/server/api/index.go b/pkg/internal/server/api/index.go index f939e47..d293cdd 100644 --- a/pkg/internal/server/api/index.go +++ b/pkg/internal/server/api/index.go @@ -9,9 +9,13 @@ import ( func MapAPIs(app *fiber.App) { wellKnown := app.Group("/.well-known").Name("Well Known") { + wellKnown.Get("/", func(c *fiber.Ctx) error { + return c.SendStatus(fiber.StatusOK) + }) wellKnown.Get("/directory/services", listExistsService) } + app.All("/cgi/:service/*", forwardServiceRequest) app.All("/srv/:service/*", forwardServiceRequest) api := app.Group("/api").Name("API")