diff --git a/main.go b/main.go index 8c956dc..78b9aac 100644 --- a/main.go +++ b/main.go @@ -50,7 +50,7 @@ func main(){ app.Get("/wiki/:id", routes.WikiRoute) app.Get("/hub", routes.ConfigsRoute) - app.Get("/hub/:id", routes.ConfigRoute) + app.Get("/hub/:name", routes.ConfigRoute) app.Get("*", func(c *fiber.Ctx) error { return lib.RenderError(c, 404) diff --git a/routes/configs.go b/routes/configs.go index 077e47e..73b6902 100644 --- a/routes/configs.go +++ b/routes/configs.go @@ -122,5 +122,19 @@ func ConfigsRoute(c *fiber.Ctx) error{ } func ConfigRoute(c *fiber.Ctx) error{ - return c.Redirect("/configs") + name := c.Params("name") + + configs, err := GetConfigs() + if err != nil { + log.Printf("GetConfigs failed: %s", err.Error()) + return lib.RenderError(c, 500) + } + + for _, cur := range configs { + if cur.Name == name { + return c.Redirect(cur.Redirect) + } + } + + return lib.RenderError(c, 404) }