NewInstallHTTPServer new install http server.
()
| 48 | |
| 49 | // NewInstallHTTPServer new install http server. |
| 50 | func NewInstallHTTPServer() *gin.Engine { |
| 51 | gin.SetMode(gin.ReleaseMode) |
| 52 | r := gin.New() |
| 53 | |
| 54 | c := &conf.AllConfig{} |
| 55 | _ = yaml.Unmarshal(configs.Config, c) |
| 56 | |
| 57 | r.GET("/healthz", func(ctx *gin.Context) { ctx.String(200, "OK") }) |
| 58 | r.StaticFS(c.UI.BaseURL+"/static", http.FS(&_resource{ |
| 59 | fs: ui.Build, |
| 60 | })) |
| 61 | |
| 62 | // read default config file and extract ui config |
| 63 | installApi := r.Group("") |
| 64 | installApi.GET(c.UI.BaseURL+"/", CheckConfigFileAndRedirectToInstallPage) |
| 65 | installApi.GET(c.UI.BaseURL+"/install", WebPage) |
| 66 | installApi.GET(c.UI.BaseURL+"/50x", WebPage) |
| 67 | installApi.GET(c.UI.APIBaseURL+"/installation/language/config", GetLangMapping) |
| 68 | installApi.GET(c.UI.APIBaseURL+"/installation/language/options", LangOptions) |
| 69 | installApi.POST(c.UI.APIBaseURL+"/installation/db/check", CheckDatabase) |
| 70 | installApi.POST(c.UI.APIBaseURL+"/installation/config-file/check", CheckConfigFile) |
| 71 | installApi.POST(c.UI.APIBaseURL+"/installation/init", InitEnvironment) |
| 72 | installApi.POST(c.UI.APIBaseURL+"/installation/base-info", InitBaseInfo) |
| 73 | |
| 74 | r.NoRoute(func(ctx *gin.Context) { |
| 75 | ctx.Redirect(http.StatusFound, "/50x") |
| 76 | }) |
| 77 | return r |
| 78 | } |
| 79 | |
| 80 | func WebPage(c *gin.Context) { |
| 81 | filePath := "" |