feat(install): The first installation automatically switches to the installation url

This commit is contained in:
LinkinStar 2022-12-26 15:41:55 +08:00
parent 2e7349fff8
commit af930eb425
2 changed files with 17 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package install
import (
"net/http"
"os"
"path/filepath"
"time"
@ -30,6 +31,21 @@ func LangOptions(ctx *gin.Context) {
handler.HandleResponse(ctx, nil, translator.LanguageOptions)
}
// CheckConfigFileAndRedirectToInstallPage if config file not exist try to redirect to install page
// @Summary if config file not exist try to redirect to install page
// @Description if config file not exist try to redirect to install page
// @Tags installation
// @Accept json
// @Produce json
// @Router / [get]
func CheckConfigFileAndRedirectToInstallPage(ctx *gin.Context) {
if cli.CheckConfigFile(confPath) {
ctx.Redirect(http.StatusFound, "/50x")
} else {
ctx.Redirect(http.StatusFound, "/install")
}
}
// CheckConfigFile check config file if exist when installation
// @Summary check config file if exist when installation
// @Description check config file if exist when installation

View File

@ -34,6 +34,7 @@ func NewInstallHTTPServer() *gin.Engine {
}))
installApi := r.Group("")
installApi.GET("/", CheckConfigFileAndRedirectToInstallPage)
installApi.GET("/install", WebPage)
installApi.GET("/50x", WebPage)
installApi.GET("/installation/language/options", LangOptions)