Merge branch 'feat/0.7.0/seo' into test

This commit is contained in:
aichy126 2022-12-15 16:48:19 +08:00
commit 7473b50469
1 changed files with 3 additions and 10 deletions

View File

@ -3,7 +3,6 @@ package server
import (
"html/template"
"io/fs"
"os"
brotli "github.com/anargu/gin-brotli"
"github.com/answerdev/answer/internal/base/middleware"
@ -32,15 +31,9 @@ func NewHTTPServer(debug bool,
r.Use(brotli.Brotli(brotli.DefaultCompression), middleware.ExtractAndSetAcceptLanguage)
r.GET("/healthz", func(ctx *gin.Context) { ctx.String(200, "OK") })
dev := os.Getenv("DEVCODE")
if dev != "" {
r.SetFuncMap(funcMap)
r.LoadHTMLGlob("../../ui/template/*")
} else {
html, _ := fs.Sub(ui.Template, "template")
htmlTemplate := template.Must(template.New("").Funcs(funcMap).ParseFS(html, "*"))
r.SetHTMLTemplate(htmlTemplate)
}
html, _ := fs.Sub(ui.Template, "template")
htmlTemplate := template.Must(template.New("").Funcs(funcMap).ParseFS(html, "*"))
r.SetHTMLTemplate(htmlTemplate)
viewRouter.Register(r)