Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Commit

Permalink
feat: root path redict to sidebar login page
Browse files Browse the repository at this point in the history
Signed-off-by: qwqcode <[email protected]>
  • Loading branch information
qwqcode committed Oct 14, 2022
1 parent 9e01dc2 commit 6fe8375
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions http/a_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ func InitRouter(e *echo.Echo) {
fileServer := http.FileServer(f)
e.Any("/*", echo.WrapHandler(fileServer))

e.Use(RootPageMiddleware())

// All Actions
action := &action{
db: lib.DB,
Expand Down Expand Up @@ -94,3 +96,19 @@ func InitRouter(e *echo.Echo) {
return c.JSON(200, GetApiVersionDataMap())
})
}

func RootPageMiddleware() echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
if c.Request().URL.Path == "/" && c.Request().Method == "GET" {
_, err := pkged.Open("/frontend/sidebar/index.html")
if err == nil {
c.Redirect(http.StatusFound, "./sidebar/")
return nil
}
}

return next(c)
}
}
}

0 comments on commit 6fe8375

Please sign in to comment.