A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
feat: add env for glob load template files by gin debug render
liruohrhd468e2ba8dee
diff --git a/internal/base/server/http.go b/internal/base/server/http.goindex 4fbb04cb..512f3da2 100644--- a/internal/base/server/http.go+++ b/internal/base/server/http.go@@ -22,6 +22,7 @@ package serverimport ("html/template""io/fs"+ "os"brotli "github.com/anargu/gin-brotli""github.com/apache/answer/internal/base/middleware"@@ -53,9 +54,14 @@ func NewHTTPServer(debug bool,r.Use(brotli.Brotli(brotli.DefaultCompression), middleware.ExtractAndSetAcceptLanguage, shortIDMiddleware.SetShortIDFlag())r.GET("/healthz", func(ctx *gin.Context) { ctx.String(200, "OK") })- html, _ := fs.Sub(ui.Template, "template")- htmlTemplate := template.Must(template.New("").Funcs(funcMap).ParseFS(html, "*"))- r.SetHTMLTemplate(htmlTemplate)+ templatePath := os.Getenv("ANSWER_TEMPLATE_PATH")+ if templatePath != "" {+ r.LoadHTMLGlob(templatePath)+ } else {+ html, _ := fs.Sub(ui.Template, "template")+ htmlTemplate := template.Must(template.New("").Funcs(funcMap).ParseFS(html, "*"))+ r.SetHTMLTemplate(htmlTemplate)+ }r.Use(middleware.HeadersByRequestURI())viewRouter.Register(r, uiConf.BaseURL)