Skip to content

Commit

Permalink
Add redirects to subpath + keep an endpoint without subpath for falco…
Browse files Browse the repository at this point in the history
…sidekick puts

Signed-off-by: Thomas Labarussias <[email protected]>
  • Loading branch information
Issif authored and poiana committed Sep 24, 2023
1 parent a19c4f4 commit be149ef
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,21 @@ func main() {
utils.WriteLog("info", fmt.Sprintf("Falcosidekick UI is listening on %v:%v", config.ListenAddress, config.ListenPort))
utils.WriteLog("info", fmt.Sprintf("Log level is %v", config.LogLevel))

if config.Subpath != "" {
e.GET("/", func(c echo.Context) error {
return c.Redirect(http.StatusPermanentRedirect, config.Subpath+"/")
})
}
e.GET(strings.TrimSuffix(config.Subpath, "/"), func(c echo.Context) error {
return c.Redirect(http.StatusPermanentRedirect, config.Subpath+"/")
})

e.GET(config.Subpath+"/docs/*", echoSwagger.WrapHandler)
e.GET(config.Subpath+"/docs", func(c echo.Context) error {
return c.Redirect(http.StatusPermanentRedirect, "docs/")
})
e.Static(config.Subpath+"/*", "frontend/dist").Name = "webui-home"
e.POST("/", api.AddEvent).Name = "add-event" // for compatibility with old Falcosidekicks
e.POST(config.Subpath+"/", api.AddEvent).Name = "add-event" // for compatibility with old Falcosidekicks

apiRoute := e.Group(config.Subpath + "/api/v1")
Expand Down

0 comments on commit be149ef

Please sign in to comment.