Status checker endpoint

This commit is contained in:
LittleSheep 2024-07-27 01:10:26 +08:00
parent fbfb340058
commit 82305206b0
2 changed files with 8 additions and 0 deletions

View File

@ -33,7 +33,11 @@ func forwardServiceRequest(c *fiber.Ctx) error {
ogUrl := c.Request().URI().String() ogUrl := c.Request().URI().String()
url := c.OriginalURL() url := c.OriginalURL()
prevUrl := url
url = strings.Replace(url, "/srv/"+serviceType, "/api", 1) url = strings.Replace(url, "/srv/"+serviceType, "/api", 1)
if prevUrl == url {
url = strings.Replace(url, "/cgi/"+serviceType, "/api", 1)
}
url = "http://" + *service.HttpAddr + url url = "http://" + *service.HttpAddr + url
log.Debug(). log.Debug().

View File

@ -9,9 +9,13 @@ import (
func MapAPIs(app *fiber.App) { func MapAPIs(app *fiber.App) {
wellKnown := app.Group("/.well-known").Name("Well Known") 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) wellKnown.Get("/directory/services", listExistsService)
} }
app.All("/cgi/:service/*", forwardServiceRequest)
app.All("/srv/:service/*", forwardServiceRequest) app.All("/srv/:service/*", forwardServiceRequest)
api := app.Group("/api").Name("API") api := app.Group("/api").Name("API")